1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-02 20:27:35 +02:00

removed IDibiVariable & DibiVariable, replaced with DibiLiteral

This commit is contained in:
David Grudl
2012-01-12 00:43:06 +01:00
parent a8672bb6ff
commit 2a5934c385
4 changed files with 43 additions and 29 deletions

View File

@@ -24,6 +24,7 @@ if (version_compare(PHP_VERSION, '5.2.0', '<')) {
require_once dirname(__FILE__) . '/libs/interfaces.php';
require_once dirname(__FILE__) . '/libs/DibiDateTime.php';
require_once dirname(__FILE__) . '/libs/DibiObject.php';
require_once dirname(__FILE__) . '/libs/DibiLiteral.php';
require_once dirname(__FILE__) . '/libs/DibiHashMap.php';
require_once dirname(__FILE__) . '/libs/DibiException.php';
require_once dirname(__FILE__) . '/libs/DibiConnection.php';
@@ -43,20 +44,6 @@ if (interface_exists('Nette\Diagnostics\IBarPanel') || interface_exists('IBarPan
/**
* @deprecated
*/
class DibiVariable extends DibiDateTime
{
function __construct($val)
{
parent::__construct($val);
trigger_error(__CLASS__ . ' is deprecated; use class DateTime instead.', E_USER_WARNING);
}
}
/**

40
dibi/libs/DibiLiteral.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
/**
* This file is part of the "dibi" - smart database abstraction layer.
*
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
/**
* SQL literal value.
*
* @author David Grudl
*/
class DibiLiteral extends DibiObject
{
/** @var string */
private $value;
public function __construct($value)
{
$this->value = (string) $value;
}
/**
* @return string
*/
public function __toString()
{
return $this->value;
}
}

View File

@@ -438,8 +438,8 @@ final class DibiTranslator extends DibiObject
} elseif ($value instanceof DateTime) {
return $this->driver->escape($value, dibi::DATETIME);
} elseif ($value instanceof IDibiVariable) {
return (string) $value->toSql();
} elseif ($value instanceof DibiLiteral) {
return (string) $value;
} else {
$this->hasError = TRUE;

View File

@@ -23,19 +23,6 @@ interface IDataSource extends Countable, IteratorAggregate
/**
* Object that is able to generate SQL.
* @package dibi
*/
interface IDibiVariable
{
function toSql();
}
/**
* dibi driver interface.
* @package dibi