mirror of
https://github.com/dg/dibi.git
synced 2025-08-22 21:54:05 +02:00
* some variables renamed
This commit is contained in:
@@ -57,19 +57,19 @@ class DibiMSSqlDriver extends DibiDriver
|
||||
$config = $this->config;
|
||||
|
||||
if (empty($config['persistent']))
|
||||
$conn = @mssql_connect($config['host'], $config['username'], $config['password'], TRUE);
|
||||
$connection = @mssql_connect($config['host'], $config['username'], $config['password'], TRUE);
|
||||
else
|
||||
$conn = @mssql_pconnect($config['host'], $config['username'], $config['password']);
|
||||
$connection = @mssql_pconnect($config['host'], $config['username'], $config['password']);
|
||||
|
||||
if (!is_resource($conn))
|
||||
if (!is_resource($connection))
|
||||
throw new DibiException("Connecting error (driver mssql)'");
|
||||
|
||||
if (!empty($config['database'])) {
|
||||
if (!@mssql_select_db($config['database'], $conn))
|
||||
if (!@mssql_select_db($config['database'], $connection))
|
||||
throw new DibiException("Connecting error (driver mssql)");
|
||||
}
|
||||
|
||||
return $conn;
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ class DibiMSSqlDriver extends DibiDriver
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
$conn = $this->getResource();
|
||||
$res = @mssql_query($sql, $conn);
|
||||
$connection = $this->getConnection();
|
||||
$res = @mssql_query($sql, $connection);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = mssql_rows_affected($conn);
|
||||
$this->affectedRows = mssql_rows_affected($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
@@ -107,19 +107,19 @@ class DibiMSSqlDriver extends DibiDriver
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return mssql_query('BEGIN TRANSACTION', $this->getResource());
|
||||
return mssql_query('BEGIN TRANSACTION', $this->getConnection());
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
return mssql_query('COMMIT', $this->getResource());
|
||||
return mssql_query('COMMIT', $this->getConnection());
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
return mssql_query('ROLLBACK', $this->getResource());
|
||||
return mssql_query('ROLLBACK', $this->getConnection());
|
||||
}
|
||||
|
||||
|
||||
|
@@ -73,15 +73,15 @@ class DibiMySqlDriver extends DibiDriver
|
||||
$php_errormsg = '';
|
||||
|
||||
if (empty($config['persistent']))
|
||||
$conn = @mysql_connect($host, $config['username'], $config['password'], TRUE);
|
||||
$connection = @mysql_connect($host, $config['username'], $config['password'], TRUE);
|
||||
else
|
||||
$conn = @mysql_pconnect($host, $config['username'], $config['password']);
|
||||
$connection = @mysql_pconnect($host, $config['username'], $config['password']);
|
||||
|
||||
if (function_exists('ini_set'))
|
||||
ini_set('track_errors', $save);
|
||||
|
||||
|
||||
if (!is_resource($conn))
|
||||
if (!is_resource($connection))
|
||||
throw new DibiException("Connecting error (driver mysql)'", array(
|
||||
'message' => mysql_error() ? mysql_error() : $php_errormsg,
|
||||
'code' => mysql_errno(),
|
||||
@@ -89,20 +89,20 @@ class DibiMySqlDriver extends DibiDriver
|
||||
|
||||
|
||||
if (!empty($config['charset'])) {
|
||||
@mysql_query("SET NAMES '" . $config['charset'] . "'", $conn);
|
||||
@mysql_query("SET NAMES '" . $config['charset'] . "'", $connection);
|
||||
// don't handle this error...
|
||||
}
|
||||
|
||||
|
||||
if (!empty($config['database'])) {
|
||||
if (!@mysql_select_db($config['database'], $conn))
|
||||
if (!@mysql_select_db($config['database'], $connection))
|
||||
throw new DibiException("Connecting error (driver mysql)", array(
|
||||
'message' => mysql_error($conn),
|
||||
'code' => mysql_errno($conn),
|
||||
'message' => mysql_error($connection),
|
||||
'code' => mysql_errno($connection),
|
||||
));
|
||||
}
|
||||
|
||||
return $conn;
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,15 +111,15 @@ class DibiMySqlDriver extends DibiDriver
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$conn = $this->getResource();
|
||||
$res = @mysql_query($sql, $conn);
|
||||
$connection = $this->getConnection();
|
||||
$res = @mysql_query($sql, $connection);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = mysql_affected_rows($conn);
|
||||
$this->affectedRows = mysql_affected_rows($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = mysql_insert_id($conn);
|
||||
$this->insertId = mysql_insert_id($connection);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
@@ -143,38 +143,38 @@ class DibiMySqlDriver extends DibiDriver
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return mysql_query('BEGIN', $this->getResource());
|
||||
return mysql_query('BEGIN', $this->getConnection());
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
return mysql_query('COMMIT', $this->getResource());
|
||||
return mysql_query('COMMIT', $this->getConnection());
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
return mysql_query('ROLLBACK', $this->getResource());
|
||||
return mysql_query('ROLLBACK', $this->getConnection());
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$connection = $this->getConnection();
|
||||
return array(
|
||||
'message' => mysql_error($conn),
|
||||
'code' => mysql_errno($conn),
|
||||
'message' => mysql_error($connection),
|
||||
'code' => mysql_errno($connection),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function escape($value, $appendQuotes=TRUE)
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$connection = $this->getConnection();
|
||||
return $appendQuotes
|
||||
? "'" . mysql_real_escape_string($value, $conn) . "'"
|
||||
: mysql_real_escape_string($value, $conn);
|
||||
? "'" . mysql_real_escape_string($value, $connection) . "'"
|
||||
: mysql_real_escape_string($value, $connection);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -64,18 +64,18 @@ class DibiMySqliDriver extends DibiDriver
|
||||
{
|
||||
$config = $this->config;
|
||||
|
||||
$conn = @mysqli_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
|
||||
$connection = @mysqli_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
|
||||
|
||||
if (!$conn)
|
||||
if (!$connection)
|
||||
throw new DibiException("Connecting error (driver mysqli)", array(
|
||||
'message' => mysqli_connect_error(),
|
||||
'code' => mysqli_connect_errno(),
|
||||
));
|
||||
|
||||
if (!empty($config['charset']))
|
||||
mysqli_query($conn, "SET NAMES '" . $config['charset'] . "'");
|
||||
mysqli_query($connection, "SET NAMES '" . $config['charset'] . "'");
|
||||
|
||||
return $conn;
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,15 +83,15 @@ class DibiMySqliDriver extends DibiDriver
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$conn = $this->getResource();
|
||||
$res = @mysqli_query($conn, $sql);
|
||||
$connection = $this->getConnection();
|
||||
$res = @mysqli_query($connection, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = mysqli_affected_rows($conn);
|
||||
$this->affectedRows = mysqli_affected_rows($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = mysqli_insert_id($conn);
|
||||
$this->insertId = mysqli_insert_id($connection);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_object($res))
|
||||
@@ -115,34 +115,34 @@ class DibiMySqliDriver extends DibiDriver
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return mysqli_autocommit($this->getResource(), FALSE);
|
||||
return mysqli_autocommit($this->getConnection(), FALSE);
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$ok = mysqli_commit($conn);
|
||||
mysqli_autocommit($conn, TRUE);
|
||||
$connection = $this->getConnection();
|
||||
$ok = mysqli_commit($connection);
|
||||
mysqli_autocommit($connection, TRUE);
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$ok = mysqli_rollback($conn);
|
||||
mysqli_autocommit($conn, TRUE);
|
||||
$connection = $this->getConnection();
|
||||
$ok = mysqli_rollback($connection);
|
||||
mysqli_autocommit($connection, TRUE);
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$connection = $this->getConnection();
|
||||
return array(
|
||||
'message' => mysqli_error($conn),
|
||||
'code' => mysqli_errno($conn),
|
||||
'message' => mysqli_error($connection),
|
||||
'code' => mysqli_errno($connection),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -151,10 +151,10 @@ class DibiMySqliDriver extends DibiDriver
|
||||
|
||||
public function escape($value, $appendQuotes=TRUE)
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$connection = $this->getConnection();
|
||||
return $appendQuotes
|
||||
? "'" . mysqli_real_escape_string($conn, $value) . "'"
|
||||
: mysqli_real_escape_string($conn, $value);
|
||||
? "'" . mysqli_real_escape_string($connection, $value) . "'"
|
||||
: mysqli_real_escape_string($connection, $value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -68,17 +68,17 @@ class DibiOdbcDriver extends DibiDriver
|
||||
$config = $this->config;
|
||||
|
||||
if (empty($config['persistent']))
|
||||
$conn = @odbc_connect($config['database'], $config['username'], $config['password']);
|
||||
$connection = @odbc_connect($config['database'], $config['username'], $config['password']);
|
||||
else
|
||||
$conn = @odbc_pconnect($config['database'], $config['username'], $config['password']);
|
||||
$connection = @odbc_pconnect($config['database'], $config['username'], $config['password']);
|
||||
|
||||
if (!is_resource($conn))
|
||||
if (!is_resource($connection))
|
||||
throw new DibiException("Connecting error (driver odbc)", array(
|
||||
'message' => odbc_errormsg(),
|
||||
'code' => odbc_error(),
|
||||
));
|
||||
|
||||
return $conn;
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,12 +87,12 @@ class DibiOdbcDriver extends DibiDriver
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
|
||||
$conn = $this->getResource();
|
||||
$res = @odbc_exec($conn, $sql);
|
||||
$connection = $this->getConnection();
|
||||
$res = @odbc_exec($connection, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = odbc_num_rows($conn);
|
||||
$this->affectedRows = odbc_num_rows($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
@@ -116,34 +116,34 @@ class DibiOdbcDriver extends DibiDriver
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return odbc_autocommit($this->getResource(), FALSE);
|
||||
return odbc_autocommit($this->getConnection(), FALSE);
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$ok = odbc_commit($conn);
|
||||
odbc_autocommit($conn, TRUE);
|
||||
$connection = $this->getConnection();
|
||||
$ok = odbc_commit($connection);
|
||||
odbc_autocommit($connection, TRUE);
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$ok = odbc_rollback($conn);
|
||||
odbc_autocommit($conn, TRUE);
|
||||
$connection = $this->getConnection();
|
||||
$ok = odbc_rollback($connection);
|
||||
odbc_autocommit($connection, TRUE);
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
$conn = $this->getResource();
|
||||
$connection = $this->getConnection();
|
||||
return array(
|
||||
'message' => odbc_errormsg($conn),
|
||||
'code' => odbc_error($conn),
|
||||
'message' => odbc_errormsg($connection),
|
||||
'code' => odbc_error($connection),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ class DibiPdoDriver extends DibiDriver
|
||||
$this->affectedRows = FALSE;
|
||||
|
||||
// TODO: or exec() ?
|
||||
$res = $this->getResource()->query($sql);
|
||||
$res = $this->getConnection()->query($sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
@@ -85,31 +85,31 @@ class DibiPdoDriver extends DibiDriver
|
||||
|
||||
public function insertId()
|
||||
{
|
||||
return $this->getResource()->lastInsertId();
|
||||
return $this->getConnection()->lastInsertId();
|
||||
}
|
||||
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return $this->getResource()->beginTransaction();
|
||||
return $this->getConnection()->beginTransaction();
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
return $this->getResource()->commit();
|
||||
return $this->getConnection()->commit();
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
return $this->getResource()->rollBack();
|
||||
return $this->getConnection()->rollBack();
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
$error = $this->getResource()->errorInfo();
|
||||
$error = $this->getConnection()->errorInfo();
|
||||
return array(
|
||||
'message' => $error[2],
|
||||
'code' => $error[1],
|
||||
@@ -124,7 +124,7 @@ class DibiPdoDriver extends DibiDriver
|
||||
trigger_error('dibi: escaping without qoutes is not supported by PDO', E_USER_WARNING);
|
||||
return NULL;
|
||||
}
|
||||
return $this->getResource()->quote($value);
|
||||
return $this->getConnection()->quote($value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -59,20 +59,20 @@ class DibiPostgreDriver extends DibiDriver
|
||||
$config = $this->config;
|
||||
|
||||
if (isset($config['persistent']))
|
||||
$conn = @pg_connect($config['string'], $config['type']);
|
||||
$connection = @pg_connect($config['string'], $config['type']);
|
||||
else
|
||||
$conn = @pg_pconnect($config['string'], $config['type']);
|
||||
$connection = @pg_pconnect($config['string'], $config['type']);
|
||||
|
||||
if (!is_resource($conn))
|
||||
if (!is_resource($connection))
|
||||
throw new DibiException("Connecting error (driver postgre)", array(
|
||||
'message' => pg_last_error(),
|
||||
));
|
||||
|
||||
if (!empty($config['charset'])) {
|
||||
@pg_set_client_encoding($conn, $config['charset']);
|
||||
@pg_set_client_encoding($connection, $config['charset']);
|
||||
// don't handle this error...
|
||||
}
|
||||
return $conn;
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ class DibiPostgreDriver extends DibiDriver
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
|
||||
$conn = $this->getResource();
|
||||
$res = @pg_query($conn, $sql);
|
||||
$connection = $this->getConnection();
|
||||
$res = @pg_query($connection, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = pg_affected_rows($conn);
|
||||
$this->affectedRows = pg_affected_rows($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
@@ -110,26 +110,26 @@ class DibiPostgreDriver extends DibiDriver
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return pg_query($this->getResource(), 'BEGIN');
|
||||
return pg_query($this->getConnection(), 'BEGIN');
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
return pg_query($this->getResource(), 'COMMIT');
|
||||
return pg_query($this->getConnection(), 'COMMIT');
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
return pg_query($this->getResource(), 'ROLLBACK');
|
||||
return pg_query($this->getConnection(), 'ROLLBACK');
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
return array(
|
||||
'message' => pg_last_error($this->getResource()),
|
||||
'message' => pg_last_error($this->getConnection()),
|
||||
'code' => NULL,
|
||||
);
|
||||
}
|
||||
|
@@ -62,16 +62,16 @@ class DibiSqliteDriver extends DibiDriver
|
||||
|
||||
$errorMsg = '';
|
||||
if (empty($config['persistent']))
|
||||
$conn = @sqlite_open($config['database'], $config['mode'], $errorMsg);
|
||||
$connection = @sqlite_open($config['database'], $config['mode'], $errorMsg);
|
||||
else
|
||||
$conn = @sqlite_popen($config['database'], $config['mode'], $errorMsg);
|
||||
$connection = @sqlite_popen($config['database'], $config['mode'], $errorMsg);
|
||||
|
||||
if (!$conn)
|
||||
if (!$connection)
|
||||
throw new DibiException("Connecting error (driver sqlite)", array(
|
||||
'message' => $errorMsg,
|
||||
));
|
||||
|
||||
return $conn;
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,15 +80,15 @@ class DibiSqliteDriver extends DibiDriver
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
|
||||
$conn = $this->getResource();
|
||||
$res = @sqlite_query($conn, $sql, SQLITE_ASSOC);
|
||||
$connection = $this->getConnection();
|
||||
$res = @sqlite_query($connection, $sql, SQLITE_ASSOC);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = sqlite_changes($conn);
|
||||
$this->affectedRows = sqlite_changes($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = sqlite_last_insert_rowid($conn);
|
||||
$this->insertId = sqlite_last_insert_rowid($connection);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
@@ -112,25 +112,25 @@ class DibiSqliteDriver extends DibiDriver
|
||||
|
||||
public function begin()
|
||||
{
|
||||
return sqlite_query($this->getResource(), 'BEGIN');
|
||||
return sqlite_query($this->getConnection(), 'BEGIN');
|
||||
}
|
||||
|
||||
|
||||
public function commit()
|
||||
{
|
||||
return sqlite_query($this->getResource(), 'COMMIT');
|
||||
return sqlite_query($this->getConnection(), 'COMMIT');
|
||||
}
|
||||
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
return sqlite_query($this->getResource(), 'ROLLBACK');
|
||||
return sqlite_query($this->getConnection(), 'ROLLBACK');
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
$code = sqlite_last_error($this->getResource());
|
||||
$code = sqlite_last_error($this->getConnection());
|
||||
return array(
|
||||
'message' => sqlite_error_string($code),
|
||||
'code' => $code,
|
||||
|
Reference in New Issue
Block a user