$val ) { switch ( $key ) { case 'user': case 'username': $user = $val; break; case 'pass': case 'password': $pass = $val; break; case 'driver-opts': $driverOptions = $val; break; } } parent::__construct( $dsn, $user, $pass, $driverOptions ); $this->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $this->setAttribute( PDO::ATTR_CASE, PDO::CASE_LOWER ); } /** * Returns the name of the handler. * * Returns handler name * (e.g. 'mysql', 'pgsql', 'oracle', etc.) * * This method can be used to choose more optimal query * for the given Database. * * @return string */ abstract static public function getName(); /** * Returns true if the given $feature is supported by the handler. * * Derived classes should override this method to report * the features they support. * * @param string $feature * @return bool */ static public function hasFeature( $feature ) { return false; } /** * Begins a transaction. * * This method executes a begin transaction query unless a * transaction has already been started (transaction nesting level > 0 ) * * Each call to begin() must have a corresponding commit() or rollback() call. * * @see commit() * @see rollback() * @return bool */ public function beginTransaction() { $retval = true; if ( $this->transactionNestingLevel == 0 ) { $retval = parent::beginTransaction(); } //else NOP $this->transactionNestingLevel++; return $retval; } /** * Commits a transaction. * * If this this call to commit corresponds to the outermost call to * begin() and all queries within this transaction were successful, * a commit query is executed. If one of the queries * returned with an error, a rollback query is executed instead. * * This method returns true if the transaction was successful. If the * transaction failed and rollback was called, false is returned. * * @see begin() * @see rollback() * @return bool */ public function commit() { if ( $this->transactionNestingLevel <= 0 ) { $this->level = 0; throw new ezcDbTransactionException( "commit() called before beginTransaction()." ); } $retval = true; if ( $this->transactionNestingLevel == 1 ) { if ( $this->transactionErrorFlag ) { parent::rollback(); $this->transactionErrorFlag = false; // reset error flag $retval = false; } else { parent::commit(); } } // else NOP $this->transactionNestingLevel--; return $retval; } /** * Rollback a transaction. * * If this this call to rollback corresponds to the outermost call to * begin(), a rollback query is executed. If this is an inner transaction * (nesting level > 1) the error flag is set, leaving the rollback to the * outermost transaction. * * This method always returns true. * * @see begin() * @see commit() * @return bool */ public function rollback() { if ( $this->transactionNestingLevel <= 0 ) { $this->transactionNestingLevel = 0; throw new ezcDbTransactionException( "rollback() called without previous beginTransaction()." ); } if ( $this->transactionNestingLevel == 1 ) { $this->transactionErrorFlag = false; // reset error flag } else { // set the error flag, so that if there is outermost commit // then ROLLBACK will be done instead of COMMIT $this->transactionErrorFlag = true; } $this->transactionNestingLevel--; return true; } /** * Returns a new ezcQuerySelect derived object for the correct database type. * * @return ezcQuerySelect */ public function createSelectQuery() { return new ezcQuerySelect( $this ); } /** * Returns a new ezcQueryUpdate derived object for the correct database type. * * @return ezcQueryUpdate */ public function createUpdateQuery() { return new ezcQueryUpdate( $this ); } /** * Returns a new ezcQueryInsert derived object for the correct database type. * * @return ezcQueryInsert */ public function createInsertQuery() { return new ezcQueryInsert( $this ); } /** * Returns a new ezcQueryDelete derived object for the correct database type. * * @return ezcQueryDelete */ public function createDeleteQuery() { return new ezcQueryDelete( $this ); } /** * Returns a new ezcQueryExpression derived object for the correct database type. * * @return ezcQueryExpression */ public function createExpression() { return new ezcQueryExpression(); } /** * Returns a new ezcUtilities derived object for the correct database type. * * @return ezcDbUtilities */ public function createUtilities() { return new ezcDbUtilities( $this ); } } ?>