mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-15 22:19:51 +00:00

I've removed the author/licence information from some files -- such as app/app_controller.php and config/database.php -- as they are not our code and those files need to remain as clean as possible for people not to get lost in them. I've run the tests on this one, but the tests are not as extensive as they should be. If you want to get the test controller etc. check out the version in my sandbox. But we'll probably be moving to SimpleTest soon anyway. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@114 3807eeeb-6ff5-0310-8944-8be069107fe0
85 lines
No EOL
1.6 KiB
PHP
85 lines
No EOL
1.6 KiB
PHP
<?PHP
|
|
/*
|
|
* Name: DBO/MySQL
|
|
* Author: Michal Tatarynowicz (tatarynowicz@gmail.com)
|
|
* Licence: Public Domain
|
|
*/
|
|
|
|
uses('object', 'dbo');
|
|
|
|
class DBO_MySQL extends DBO {
|
|
|
|
function connect ($config) {
|
|
if($config) {
|
|
$this->config = $config;
|
|
$this->_conn = mysql_pconnect($config['host'],$config['login'],$config['password']);
|
|
}
|
|
$this->connected = $this->_conn? true: false;
|
|
|
|
if($this->connected)
|
|
Return mysql_select_db($config['database'], $this->_conn);
|
|
else
|
|
die('Could not connect to DB.');
|
|
}
|
|
|
|
function disconnect () {
|
|
return mysql_close();
|
|
}
|
|
|
|
function execute ($sql) {
|
|
return mysql_query($sql);
|
|
}
|
|
|
|
function fetchRow ($res) {
|
|
return mysql_fetch_array($res);
|
|
}
|
|
|
|
function tables () {
|
|
$result = mysql_list_tables($this->config['database']);
|
|
|
|
if (!$result) {
|
|
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
|
exit;
|
|
}
|
|
else {
|
|
$tables = array();
|
|
while ($line = mysql_fetch_array($result)) {
|
|
$tables[] = $line[0];
|
|
}
|
|
return $tables;
|
|
}
|
|
}
|
|
|
|
function fields ($table_name) {
|
|
$data = $this->all("DESC {$table_name}");
|
|
$fields = false;
|
|
|
|
foreach ($data as $item)
|
|
$fields[] = array('name'=>$item['Field'], 'type'=>$item['Type']);
|
|
|
|
return $fields;
|
|
}
|
|
|
|
function prepare ($data) {
|
|
return "'".str_replace("'", "\\'", $data)."'";
|
|
}
|
|
|
|
function lastError () {
|
|
return mysql_errno()? mysql_errno().': '.mysql_error(): null;
|
|
}
|
|
|
|
function lastAffected () {
|
|
return $this->_result? mysql_affected_rows(): false;
|
|
}
|
|
|
|
function lastNumRows () {
|
|
return $this->_result? @mysql_num_rows($this->_result): false;
|
|
}
|
|
|
|
function lastInsertId() {
|
|
Return mysql_insert_id();
|
|
}
|
|
|
|
}
|
|
|
|
?>
|