db = $database; } /** * Returns a string containing the most recent SQL query * processed by the database adapter, thus conforming to the * interface: * * @see Adapter::getSQL * * Methods like get(), getRow() and exec() cause this SQL cache * to get filled. If no SQL query has been processed yet this function * will return an empty string. * * @return string */ public function getSQL() { return $this->sql; } /** * @see Adapter::exec */ public function exec( $sql, $bindings = array(), $noevent = FALSE ) { if ( !$noevent ) { $this->sql = $sql; $this->signal( 'sql_exec', $this ); } return $this->db->Execute( $sql, $bindings ); } /** * @see Adapter::get */ public function get( $sql, $bindings = array() ) { $this->sql = $sql; $this->signal( 'sql_exec', $this ); return $this->db->GetAll( $sql, $bindings ); } /** * @see Adapter::getRow */ public function getRow( $sql, $bindings = array() ) { $this->sql = $sql; $this->signal( 'sql_exec', $this ); return $this->db->GetRow( $sql, $bindings ); } /** * @see Adapter::getCol */ public function getCol( $sql, $bindings = array() ) { $this->sql = $sql; $this->signal( 'sql_exec', $this ); return $this->db->GetCol( $sql, $bindings ); } /** * @see Adapter::getAssoc */ public function getAssoc( $sql, $bindings = array() ) { $this->sql = $sql; $this->signal( 'sql_exec', $this ); $rows = $this->db->GetAll( $sql, $bindings ); $assoc = array(); if ( !$rows ) { return $assoc; } foreach ( $rows as $row ) { if ( empty( $row ) ) continue; if ( count( $row ) > 2 ) { $key = array_shift( $row ); $value = $row; } elseif ( count( $row ) > 1 ) { $key = array_shift( $row ); $value = array_shift( $row ); } else { $key = array_shift( $row ); $value = $key; } $assoc[$key] = $value; } return $assoc; } /** * @see Adapter::getAssocRow */ public function getAssocRow($sql, $bindings = array()) { $this->sql = $sql; $this->signal( 'sql_exec', $this ); return $this->db->GetAssocRow( $sql, $bindings ); } /** * @see Adapter::getCell */ public function getCell( $sql, $bindings = array(), $noSignal = NULL ) { $this->sql = $sql; if ( !$noSignal ) $this->signal( 'sql_exec', $this ); return $this->db->GetOne( $sql, $bindings ); } /** * @see Adapter::getCursor */ public function getCursor( $sql, $bindings = array() ) { return $this->db->GetCursor( $sql, $bindings ); } /** * @see Adapter::getInsertID */ public function getInsertID() { return $this->db->getInsertID(); } /** * @see Adapter::getAffectedRows */ public function getAffectedRows() { return $this->db->Affected_Rows(); } /** * @see Adapter::getDatabase */ public function getDatabase() { return $this->db; } /** * @see Adapter::startTransaction */ public function startTransaction() { $this->db->StartTrans(); } /** * @see Adapter::commit */ public function commit() { $this->db->CommitTrans(); } /** * @see Adapter::rollback */ public function rollback() { $this->db->FailTrans(); } /** * @see Adapter::close. */ public function close() { $this->db->close(); } }