mirror of
https://github.com/dg/dibi.git
synced 2025-08-14 01:54:08 +02:00
* DibiPdoDriver bugs fixed
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
|
- PDO driver (current PDO driver is alpha version)
|
||||||
- better examples
|
- better examples
|
||||||
- documentation
|
- documentation
|
||||||
|
@@ -29,9 +29,7 @@ class DibiPdoDriver extends DibiDriver
|
|||||||
/** @var PDO */
|
/** @var PDO */
|
||||||
private $conn;
|
private $conn;
|
||||||
|
|
||||||
private $affectedRows = FALSE,
|
private $affectedRows = FALSE;
|
||||||
|
|
||||||
private $errorMsg;
|
|
||||||
|
|
||||||
public
|
public
|
||||||
$formats = array(
|
$formats = array(
|
||||||
@@ -67,16 +65,13 @@ class DibiPdoDriver extends DibiDriver
|
|||||||
{
|
{
|
||||||
$this->affectedRows = FALSE;
|
$this->affectedRows = FALSE;
|
||||||
|
|
||||||
$this->errorMsg = '';
|
// TODO: or exec() ?
|
||||||
$res = $this->conn->query($sql);
|
$res = $this->conn->query($sql);
|
||||||
|
|
||||||
if ($res === FALSE) return FALSE;
|
if ($res === FALSE) return FALSE;
|
||||||
|
|
||||||
//$this->affectedRows = 0;
|
if ($res instanceof PDOStatement)
|
||||||
//if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
return new DibiPdoResult($res);
|
||||||
|
|
||||||
if (is_resource($res))
|
|
||||||
return new DibiSqliteResult($res);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -125,15 +120,18 @@ class DibiPdoDriver extends DibiDriver
|
|||||||
|
|
||||||
public function escape($value, $appendQuotes = FALSE)
|
public function escape($value, $appendQuotes = FALSE)
|
||||||
{
|
{
|
||||||
return $appendQuotes
|
if (!$appendQuotes) {
|
||||||
? $this->conn->quote($value)
|
trigger_error('dibi: escaping without qoutes is not supported by PDO', E_USER_WARNING);
|
||||||
: FALSE; // error
|
return NULL;
|
||||||
|
}
|
||||||
|
return $this->conn->quote($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function quoteName($value)
|
public function quoteName($value)
|
||||||
{
|
{
|
||||||
return FALSE; // error
|
// quoting is not supported by PDO
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -150,8 +148,7 @@ class DibiPdoDriver extends DibiDriver
|
|||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset = 0)
|
public function applyLimit(&$sql, $limit, $offset = 0)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
trigger_error('Meta is not implemented.', E_USER_WARNING);
|
||||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // class DibiPdoDriver
|
} // class DibiPdoDriver
|
||||||
@@ -207,7 +204,8 @@ class DibiPdoResult extends DibiResult
|
|||||||
$count = $this->resource->columnCount();
|
$count = $this->resource->columnCount();
|
||||||
$this->meta = $this->convert = array();
|
$this->meta = $this->convert = array();
|
||||||
for ($index = 0; $index < $count; $index++) {
|
for ($index = 0; $index < $count; $index++) {
|
||||||
$meta = $this->resource->getColumnMeta($i);
|
$meta = $this->resource->getColumnMeta($index);
|
||||||
|
// TODO:
|
||||||
$meta['type'] = dibi::FIELD_UNKNOWN;
|
$meta['type'] = dibi::FIELD_UNKNOWN;
|
||||||
$name = $meta['name'];
|
$name = $meta['name'];
|
||||||
$this->meta[$name] = $meta;
|
$this->meta[$name] = $meta;
|
||||||
|
@@ -44,6 +44,13 @@ try {
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
// connects to PDO
|
||||||
|
dibi::connect(array(
|
||||||
|
'driver' => 'pdo',
|
||||||
|
'dsn' => 'sqlite2::memory:',
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
} catch (DibiException $e) {
|
} catch (DibiException $e) {
|
||||||
|
|
||||||
echo "DibiException: <pre>", $e;
|
echo "DibiException: <pre>", $e;
|
||||||
|
Reference in New Issue
Block a user