[PHP-DB] Sorting Multidimensional Array
Hi, RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow; } The purpose is to retrieve the table data and manually add a record, then sort ASC by the startdate which is the forth field... Something like: $test = array_multisort($query, $key = '$query[4]'); Any help would be greatly appreciated. Thanks, Larentium
[PHP-DB] Undefined pg_prepare() in 5.6.1
Hello, The following code: ?php // Connect to a database named mary $dbconn = pg_connect(host=localhost port=5432 dbname=test user=test password=test); if(!$dbconn) { echo Unable to connect to test database\n; echo pg_last_errror($dbconn); exit; } $result = pg_prepare($dbconn, my_query, 'SELECT * FROM users WHERE username = $1'); ... ? gives me this in the apache log: [Tue Oct 31 15:11:42 2006] [error] [client xx.xxx.xxx.x] PHP Fatal error: Call to undefined function pg_prepare() in /usr/local/apache/htdocs/php/dbtest.php on line 10 Other than this, PHP and non-prepare related pg_* functions work fine. php_info() reports that it sees version 8.0.3 of libpq. I've done a fresh compile and install of apache and PHP. Versions are: Apache: 2.2.3 PHP: 5.6.1 Postgres: 8.0.3 My configure line for PHP was: ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext I've not been able to find any help on this in the FAQ or by searching the archives. It seems like this must be something really stupid, but I'm stumped. Any help/pointers would be greatly appreciated. -Steve -- ( Stephen L. Mathias, Ph.D. ( s m a t h i a s ( ) Division of Biocomputing) @ p o b l a n o ) ( UNM School of Medicine ( . h e a l t h . ( ) ) u n m . e d u ) ( http://poblano.health.unm.edu/( -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Sorting Multidimensional Array
Keith Spiller wrote: Hi, RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow; } The purpose is to retrieve the table data and manually add a record, then sort ASC by the startdate which is the forth field... Something like: $test = array_multisort($query, $key = '$query[4]'); Any help would be greatly appreciated. Thanks, Is there a reason you want to do this in php rather than through the database itself? Through the database, just add: order by fieldname asc; to the end of the query. If you can't do it that way for whatever reason, post some sample data and what you want to get out of it. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Sorting Multidimensional Array
You should be able to use usort() On 10/31/06, Keith Spiller [EMAIL PROTECTED] wrote: Hi, RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow; } The purpose is to retrieve the table data and manually add a record, then sort ASC by the startdate which is the forth field... Something like: $test = array_multisort($query, $key = '$query[4]'); Any help would be greatly appreciated. Thanks, Larentium -- Dave W
Re: [PHP-DB] Undefined pg_prepare() in 5.6.1
Steve Mathias wrote: Hello, The following code: ?php // Connect to a database named mary $dbconn = pg_connect(host=localhost port=5432 dbname=test user=test password=test); if(!$dbconn) { echo Unable to connect to test database\n; echo pg_last_errror($dbconn); exit; } $result = pg_prepare($dbconn, my_query, 'SELECT * FROM users WHERE username = $1'); ... ? gives me this in the apache log: [Tue Oct 31 15:11:42 2006] [error] [client xx.xxx.xxx.x] PHP Fatal error: Call to undefined function pg_prepare() in /usr/local/apache/htdocs/php/dbtest.php on line 10 Other than this, PHP and non-prepare related pg_* functions work fine. php_info() reports that it sees version 8.0.3 of libpq. I've done a fresh compile and install of apache and PHP. Versions are: Well there is no php 5.6.1 ;) there is a 5.1.6 though and it should work there. What shows up if you do a simple: ?php print_r(get_extension_funcs(pgsql)); ? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Undefined pg_prepare() in 5.6.1
Steve Mathias wrote: Chris == Chris [EMAIL PROTECTED] writes: Chris Steve Mathias wrote: Hello, The following code: ?php // Connect to a database named mary $dbconn = pg_connect(host=localhost port=5432 dbname=test user=test password=test); if(!$dbconn) { echo Unable to connect to test database\n; echo pg_last_errror($dbconn); exit; } $result = pg_prepare($dbconn, my_query, 'SELECT * FROM users WHERE username = $1'); ... ? gives me this in the apache log: [Tue Oct 31 15:11:42 2006] [error] [client xx.xxx.xxx.x] PHP Fatal error: Call to undefined function pg_prepare() in /usr/local/apache/htdocs/php/dbtest.php on line 10 Other than this, PHP and non-prepare related pg_* functions work fine. php_info() reports that it sees version 8.0.3 of libpq. I've done a fresh compile and install of apache and PHP. Versions are: Chris Well there is no php 5.6.1 ;) there is a 5.1.6 though and it Chris should work there. Ooops. Dyslexia sucks. Indeed, I am using 5.1.6 Chris What shows up if you do a simple: Chris ?php print_r(get_extension_funcs(pgsql)); ? An array of function names, not including pg_prepare() ;-( snipped Might need to ask the -installs list (the -general one *may* have an idea but the installs list would be better). Looks like the stuff added after 5.1.0rc1 isn't showing up (pg_query_params isn't there either). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Undefined pg_prepare() in 5.6.1
Apache: 2.2.3 PHP: 5.6.1 - 5.1.6 Postgres: 8.0.3 I think the version is ok. You can check this file PHP_Source/ext/pgsql/config.h ( after configure but before make ) to look up if HAVE_PQPREPARE is defined or undefined. If it's not, modify it to be defined munually, then launch another make. I hope this dirty solution works. --shuping zhou