mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- added DibiVariable (experimental)
- fixed bug in DibiPostgreDriver::insertId()
This commit is contained in:
@@ -42,6 +42,7 @@ require_once __FILE__ . '/../libs/DibiResult.php';
|
|||||||
require_once __FILE__ . '/../libs/DibiResultIterator.php';
|
require_once __FILE__ . '/../libs/DibiResultIterator.php';
|
||||||
require_once __FILE__ . '/../libs/DibiTranslator.php';
|
require_once __FILE__ . '/../libs/DibiTranslator.php';
|
||||||
require_once __FILE__ . '/../libs/DibiLogger.php';
|
require_once __FILE__ . '/../libs/DibiLogger.php';
|
||||||
|
require_once __FILE__ . '/../libs/DibiVariable.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -265,6 +265,7 @@ class DibiMsSqlDriver extends NObject implements DibiDriverInterface
|
|||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
mssql_free_result($this->resultset);
|
mssql_free_result($this->resultset);
|
||||||
|
$this->resultset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -310,6 +310,7 @@ class DibiMySqlDriver extends NObject implements DibiDriverInterface
|
|||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
mysql_free_result($this->resultset);
|
mysql_free_result($this->resultset);
|
||||||
|
$this->resultset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -297,6 +297,7 @@ class DibiMySqliDriver extends NObject implements DibiDriverInterface
|
|||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
mysqli_free_result($this->resultset);
|
mysqli_free_result($this->resultset);
|
||||||
|
$this->resultset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -279,6 +279,7 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
|||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
odbc_free_result($this->resultset);
|
odbc_free_result($this->resultset);
|
||||||
|
$this->resultset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -272,6 +272,7 @@ class DibiOracleDriver extends NObject implements DibiDriverInterface
|
|||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
oci_free_statement($this->resultset);
|
oci_free_statement($this->resultset);
|
||||||
|
$this->resultset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -140,14 +140,14 @@ class DibiPostgreDriver extends NObject implements DibiDriverInterface
|
|||||||
{
|
{
|
||||||
if ($sequence === NULL) {
|
if ($sequence === NULL) {
|
||||||
// PostgreSQL 8.1 is needed
|
// PostgreSQL 8.1 is needed
|
||||||
$res = $this->query("SELECT LASTVAL() AS seq");
|
$has = $this->query("SELECT LASTVAL() AS seq");
|
||||||
} else {
|
} else {
|
||||||
$res = $this->query("SELECT CURRVAL('$sequence') AS seq");
|
$has = $this->query("SELECT CURRVAL('$sequence') AS seq");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource($res)) {
|
if ($has) {
|
||||||
$row = pg_fetch_assoc($res);
|
$row = $this->fetch();
|
||||||
pg_free_result($res);
|
$this->free();
|
||||||
return $row['seq'];
|
return $row['seq'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,6 +277,7 @@ class DibiPostgreDriver extends NObject implements DibiDriverInterface
|
|||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
pg_free_result($this->resultset);
|
pg_free_result($this->resultset);
|
||||||
|
$this->resultset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -191,23 +191,3 @@ interface DibiDriverInterface
|
|||||||
function getDibiReflection();
|
function getDibiReflection();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for user variable, used for generating SQL
|
|
||||||
* @package dibi
|
|
||||||
*/
|
|
||||||
interface DibiVariableInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Format for SQL
|
|
||||||
*
|
|
||||||
* @param object destination DibiDriverInterface
|
|
||||||
* @param string optional modifier
|
|
||||||
* @return string SQL code
|
|
||||||
*/
|
|
||||||
public function toSql(DibiDriverInterface $driver, $modifier);
|
|
||||||
}
|
|
||||||
|
63
dibi/libs/DibiVariable.php
Normal file
63
dibi/libs/DibiVariable.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dibi - tiny'n'smart database abstraction layer
|
||||||
|
* ----------------------------------------------
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005, 2007 David Grudl aka -dgx- (http://www.dgx.cz)
|
||||||
|
*
|
||||||
|
* This source file is subject to the "dibi license" that is bundled
|
||||||
|
* with this package in the file license.txt.
|
||||||
|
*
|
||||||
|
* For more information please see http://php7.org/dibi/
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2005, 2007 David Grudl
|
||||||
|
* @license http://php7.org/dibi/license dibi license
|
||||||
|
* @link http://php7.org/dibi/
|
||||||
|
* @package dibi
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for user variable, used for generating SQL
|
||||||
|
* @package dibi
|
||||||
|
*/
|
||||||
|
interface DibiVariableInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Format for SQL
|
||||||
|
*
|
||||||
|
* @param object destination DibiDriverInterface
|
||||||
|
* @param string optional modifier
|
||||||
|
* @return string SQL code
|
||||||
|
*/
|
||||||
|
public function toSql(DibiDriverInterface $driver, $modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DibiVariable extends NObject implements DibiVariableInterface
|
||||||
|
{
|
||||||
|
/** @var mixed */
|
||||||
|
public $value;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct($value, $type)
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
$this->type = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function toSql(DibiDriverInterface $driver, $modifier)
|
||||||
|
{
|
||||||
|
return $driver->format($this->value, $this->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user