![]() |
|
![]() |
|
|
Detailed DescriptionThe eZDB class provides database wrapper functions The eZ db library procides a database independent framework for SQL databases. The current supported databases are: PostgreSQL and MySQL.eZ db is designed to be used with the following type subset of SQL: int, float, varchar and text. To store date and time values int's are used. eZ locale is used to present the date and times on a localized format. That way we don't have to worry about the different date and time formats used in the different databases. Auto incrementing numbers, sequences, are used to generate unique id's for a table row. This functionality is abstracted as it works different in the different databases. Limit and offset functionality is also abstracted by the eZ db library. eZ db is designed to use lowercase in all table/column names. This is done to prevent errors as the different databases handles this differently. Especially when returning the data as an associative array.
// include the library include_once( 'lib/ezdb/classes/ezdb.php' ); // Get the current database instance // will create a new database object and connect to the database backend // if there is already created an instance for this session the existing // object will be returned. // the settings for the database connections are set in site.ini $db =& eZDB::instance(); // Run a simple query $db->query( 'DELETE FROM sql_test' ); // insert some data $str = $db->escapeString( "Testing escaping'\"" ); $db->query( "INSERT INTO sql_test ( name, description ) VALUES ( 'New test', '$str' )" ); // Get the last serial value for the sql_test table $rowID = $db->lastSerialID( 'sql_test', 'id' ); // fetch some data into an array of associative arrays $rows =& $db->arrayQuery( 'SELECT * FROM sql_test' ); foreach ( $rows as $row ) { print( $row['name']�); } // fetch some data with a limit // will return the 10 first rows in the result $ret =& $db->arrayQuery( 'SELECT id, name, description, rownum FROM sql_test', array( 'offset' => 0, 'limit' => 10 ) ); // check which implementation we're running print( $db->databaseName() );
Definition at line ezdb.php. Constructor & Destructor Documentation
Member Function Documentation
The documentation for this class was generated from the following file: |