mirror of
https://github.com/dg/dibi.git
synced 2025-08-12 09:04:24 +02:00
- added DibiVariable (experimental)
- fixed bug in DibiPostgreDriver::insertId()
This commit is contained in:
@@ -191,23 +191,3 @@ interface DibiDriverInterface
|
||||
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