

|
Let us be your sole support! |
|
Hints and Tips for PHP and Postgresql |
|
To call a postgresql database in PHP: Create a connection string: $connect_string=“dbname=your_database_name user=your_ user_name password=your_password”; Create a connection $db_connect= pg_connect($connect_string); Create your query string $query_string=“SELECT * from my_table”; Execute your query and create a result set: $result = pg_query($db_conn, $query); Result set is optional—to just execute an update or delete command and you do not care to verify the completion, you do not need the $result=
To return the number of rows your query returned: $number_of_rows=pg_num_rows($result); To get a single record: $my_record= pg_fetch_array($query); This returns an array $my_record[] where each of the record’s information can be referenced either using numerical (0,1,2,3) matching the order they were selected in or the table structure for * eg $my_record[0] which returns the information in the first column Or by the name of the column $my_record[“name_of_col_1”] You can use a while statement to run through all the result set records. while($my_record= pg_fetch_array($query))
...more to come... |
|
Useful bits |
|
Blue Shoes Limited |
|
For full documentation: — Try here: |
|
Blue Shoes Limited Phone: 204-477-6872 Fax: 204-474-1969 Toll Free: 1-866-847-4277 E-mail: info@blueshoes.ca |
|
For more information |
|
Copyright © 2003-2005, Blue Shoes Limited. All rights reserved. All Logos, links and Trademarks are used with permission by holders/owners. |