parent::rollback($model)) {
return $this->_adodb->RollbackTrans();
}
return false;
}
/**
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @return array Array of tablenames in the database
*/
function listSources() {
$tables = $this->_adodb->MetaTables('TABLES');
if (!sizeof($tables) > 0) {
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
exit;
}
return $tables;
}
/**
* Returns an array of the fields in the table used by the given model.
*
* @param AppModel $model Model object
* @return array Fields in table. Keys are name and type
*/
function describe(&$model) {
$cache = parent::describe($model);
if ($cache != null) {
return $cache;
}
$fields = false;
$cols = $this->_adodb->MetaColumns($this->fullTableName($model, false));
foreach($cols as $column) {
$fields[] = array('name' => $column->name,
'type' => $this->column($column->type));
}
$this->__cacheDescription($this->fullTableName($model, false), $fields);
return $fields;
}
/**
* Returns a formatted error message from previous database operation.
*
* @return string Error message
*/
function lastError() {
return $this->_adodb->ErrorMsg();
}
/**
* Returns number of affected rows in previous database operation, or false if no previous operation exists.
*
* @return int Number of affected rows
*/
function lastAffected() {
return $this->_adodb->Affected_Rows();
}
/**
* Returns number of rows in previous resultset, or false if no previous resultset exists.
*
* @return int Number of rows in resultset
*/
function lastNumRows() {
return $this->_result ? $this->_result->RecordCount() : false;
}
/**
* Returns the ID generated from the previous INSERT operation.
*
* @return int
*
* @Returns the last autonumbering ID inserted. Returns false if function not supported.
*/
function lastInsertId() {
return $this->_adodb->Insert_ID();
}
/**
* Returns a LIMIT statement in the correct format for the particular database.
*
* @param int $limit Limit of results returned
* @param int $offset Offset from which to start results
* @return string SQL limit/offset statement
* @todo Please change output string to whatever select your database accepts. adodb doesn't allow us to get the correct limit string out of it.
*/
function limit($limit, $offset = null) {
if (empty($limit)) {
return null;
}
return " LIMIT {$limit}" . ($offset ? "{$offset}" : null);
// please change to whatever select your database accepts
// adodb doesn't allow us to get the correct limit string out of it
}
/**
* Converts database-layer column types to basic types
*
* @param string $real Real database-layer column type (i.e. "varchar(255)")
* @return string Abstract column type (i.e. "string")
*/
function column($real) {
if (isset($this->_result)) {
$adodb_metatyper = &$this->_result;
} else {
$adodb_metatyper = &$this->_adodb->execute('Select 1');
}
$interpreted_type = $adodb_metatyper->MetaType($real);
if (!isset($this->_adodb_column_types[$interpreted_type])) {
return 'text';
}
return $this->_adodb_column_types[$interpreted_type];
}
/**
* Returns a quoted and escaped string of $data for use in an SQL statement.
*
* @param string $data String to be prepared for use in an SQL sta