1
0
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:
David Grudl
2007-11-22 10:35:23 +00:00
parent 981a1adaad
commit 3f42b2cf55
9 changed files with 75 additions and 25 deletions

View File

@@ -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);
}

View 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);
}
}