note 33049 added to function.ibase-connect

From: Date: Sun, 15 Jun 2003 04:22:50 +0000
Subject: note 33049 added to function.ibase-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-50361@lists.php.net to get a copy of this message
I found it difficult to get anything working using the current documentation. While logic would suggest that the format in the docs should work (being based on all the syntax of other standard database access functions) I had problem after problem. Finally I found some comments on a newgroup that helped, and this is the result. This is actual production code (not a mere example). It works. Don't ask me why it is so different from the official docs. if ( ibase_connect( $db_filespec,$db_user,$db_pass_word) ) { $query = "SELECT c.id, c.title, c.description "; $query .= "FROM collections c "; $query .= "WHERE (c.id = $page_id) "; $result = ibase_query( $query ); $row_array = ibase_fetch_row($result); $row_fetched = !empty($row_array); if ($row_fetched) { // Extract the row into variables $collection_id = $row_array[0]; $edit_title = $row_array[1]; $edit_desc = $row_array[2]; // Standardise the record contents $collection_id = $collection_id + 0; // force type to numeric } // Wrap up the database side of things ibase_commit(); // note parenthesis but no parameters. ibase_close; // note total lack of parenthesis and parameters ! } You'll notice that there is no reference to a database handle in this code. It seems to be implicit when dealing with interbase functions. Certainly, I couldn't get the code to work when using it explicitly. This makes the documentation very hard to work with, and any reference to a handle needs to be ignored. Important: ibase_close doesn't work for me if I put parenthesis after it. eg: ibase_close; // works ibase_close(); // fails ibase_close($db); // fails Note: the line "if ($row_fetched)" could be replaced with "while ($row_fetched)" if you need to process more than one record. All that said, Interbase is a fantastic database to work with and IMHO a much better choice than something like PostgreSQL if you need to move up from MySQL to something more industrial strength. Just be sure to RTFM. ---- Manual Page -- http://www.php.net/manual/en/function.ibase-connect.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33049 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33049&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33049&report=yes

« previous php.notes (#50361) next »