mirror of
https://github.com/dg/dibi.git
synced 2025-08-26 07:24:25 +02:00
+ rewritten support for logging & error handling
+ modifier %sn * modifier %sql * changed modifier behaviour: NULL is always 'NULL'
This commit is contained in:
@@ -32,7 +32,6 @@ class DibiMySqlDriver extends DibiDriver {
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'NULL' => "NULL",
|
||||
'TRUE' => "1",
|
||||
'FALSE' => "0",
|
||||
'date' => "'Y-m-d'",
|
||||
@@ -107,16 +106,11 @@ class DibiMySqlDriver extends DibiDriver {
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$res = @mysql_query($sql, $this->conn);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiMySqlResult($res);
|
||||
|
||||
if ($res === FALSE)
|
||||
throw new DibiException("Query error", array(
|
||||
'message' => mysql_error($this->conn),
|
||||
'code' => mysql_errno($this->conn),
|
||||
'sql' => $sql,
|
||||
));
|
||||
|
||||
$this->affectedRows = mysql_affected_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
@@ -157,6 +151,15 @@ class DibiMySqlDriver extends DibiDriver {
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
return array(
|
||||
'message' => mysql_error($this->conn),
|
||||
'code' => mysql_errno($this->conn),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function escape($value, $appendQuotes = FALSE)
|
||||
{
|
||||
return $appendQuotes
|
||||
|
@@ -32,7 +32,6 @@ class DibiMySqliDriver extends DibiDriver {
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'NULL' => "NULL",
|
||||
'TRUE' => "1",
|
||||
'FALSE' => "0",
|
||||
'date' => "'Y-m-d'",
|
||||
@@ -74,12 +73,11 @@ class DibiMySqliDriver extends DibiDriver {
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$res = @mysqli_query($this->conn, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_object($res))
|
||||
return new DibiMySqliResult($res);
|
||||
|
||||
if ($res === FALSE)
|
||||
throw new DibiException("Query error", $this->errorInfo($sql));
|
||||
|
||||
$this->affectedRows = mysqli_affected_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
@@ -124,12 +122,11 @@ class DibiMySqliDriver extends DibiDriver {
|
||||
}
|
||||
|
||||
|
||||
private function errorInfo($sql = NULL)
|
||||
public function errorInfo()
|
||||
{
|
||||
return array(
|
||||
'message' => mysqli_error($this->conn),
|
||||
'code' => mysqli_errno($this->conn),
|
||||
'sql' => $sql,
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,6 @@ class DibiOdbcDriver extends DibiDriver {
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'NULL' => "NULL",
|
||||
'TRUE' => "-1",
|
||||
'FALSE' => "0",
|
||||
'date' => "#m/d/Y#",
|
||||
@@ -75,12 +74,11 @@ class DibiOdbcDriver extends DibiDriver {
|
||||
|
||||
$res = @odbc_exec($this->conn, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiOdbcResult($res);
|
||||
|
||||
if ($res === FALSE)
|
||||
throw new DibiException("Query error", $this->errorInfo($sql));
|
||||
|
||||
$this->affectedRows = odbc_num_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
@@ -122,12 +120,11 @@ class DibiOdbcDriver extends DibiDriver {
|
||||
}
|
||||
|
||||
|
||||
private function errorInfo($sql = NULL)
|
||||
public function errorInfo()
|
||||
{
|
||||
return array(
|
||||
'message' => odbc_errormsg($this->conn),
|
||||
'code' => odbc_error($this->conn),
|
||||
'sql' => $sql,
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,6 @@ class DibiPostgreDriver extends DibiDriver {
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'NULL' => "NULL",
|
||||
'TRUE' => "1",
|
||||
'FALSE' => "0",
|
||||
'date' => "'Y-m-d'",
|
||||
@@ -80,15 +79,11 @@ class DibiPostgreDriver extends DibiDriver {
|
||||
$errorMsg = '';
|
||||
$res = @pg_query($this->conn, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiPostgreResult($res);
|
||||
|
||||
if ($res === FALSE)
|
||||
throw new DibiException("Query error", array(
|
||||
'message' => pg_last_error($this->conn),
|
||||
'sql' => $sql,
|
||||
));
|
||||
|
||||
$this->affectedRows = pg_affected_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
@@ -126,6 +121,15 @@ class DibiPostgreDriver extends DibiDriver {
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
return array(
|
||||
'message' => pg_last_error($this->conn),
|
||||
'code' => NULL,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function escape($value, $appendQuotes = FALSE)
|
||||
{
|
||||
return $appendQuotes
|
||||
|
@@ -28,11 +28,11 @@ class DibiSqliteDriver extends DibiDriver {
|
||||
private
|
||||
$conn,
|
||||
$insertId = FALSE,
|
||||
$affectedRows = FALSE;
|
||||
$affectedRows = FALSE,
|
||||
$errorMsg;
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'NULL' => "NULL",
|
||||
'TRUE' => "1",
|
||||
'FALSE' => "0",
|
||||
'date' => "'Y-m-d'",
|
||||
@@ -75,13 +75,9 @@ class DibiSqliteDriver extends DibiDriver {
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
|
||||
$errorMsg = '';
|
||||
$res = @sqlite_query($this->conn, $sql, SQLITE_ASSOC, $errorMsg);
|
||||
$res = @sqlite_query($this->conn, $sql, SQLITE_ASSOC, $this->errorMsg);
|
||||
|
||||
if ($res === FALSE)
|
||||
throw new DibiException("Query error", array(
|
||||
'message' => $errorMsg,
|
||||
'sql' => $sql,
|
||||
));
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiSqliteResult($res);
|
||||
@@ -126,6 +122,15 @@ class DibiSqliteDriver extends DibiDriver {
|
||||
}
|
||||
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
return array(
|
||||
'message' => $this->errorMsg,
|
||||
'code' => NULL,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function escape($value, $appendQuotes = FALSE)
|
||||
{
|
||||
return $appendQuotes
|
||||
|
Reference in New Issue
Block a user