1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-12 17:14:16 +02:00

removed PHP 5.1 support; removed DibiVariable & IDibiVariable

This commit is contained in:
David Grudl
2009-11-16 01:44:10 +01:00
parent 8586eb8e29
commit 75ede18f94
8 changed files with 26 additions and 134 deletions

View File

@@ -636,12 +636,9 @@ class DibiResult extends DibiObject implements IDataSource
} elseif (is_numeric($value)) { // single timestamp
return date($format, $value);
} elseif (class_exists('DateTime', FALSE)) { // since PHP 5.2
} else {
$value = new DateTime($value);
return $value->format($format);
} else {
return date($format, strtotime($value));
}
case dibi::BOOL:

View File

@@ -60,12 +60,9 @@ class DibiRow extends ArrayObject
} elseif (is_numeric($time)) { // single timestamp
return date($format, $time);
} elseif (class_exists('DateTime', FALSE)) { // since PHP 5.2
} else {
$time = new DateTime($time);
return $time->format($format);
} else {
return date($format, strtotime($time));
}
}

View File

@@ -326,10 +326,7 @@ final class DibiTranslator extends DibiObject
// with modifier procession
if ($modifier) {
if ($value instanceof IDibiVariable) {
return $value->toSql($this, $modifier);
} elseif ($value !== NULL && !is_scalar($value) && !($value instanceof DateTime)) { // array is already processed
if ($value !== NULL && !is_scalar($value) && !($value instanceof DateTime)) { // array is already processed
$this->hasError = TRUE;
return '**Unexpected type ' . gettype($value) . '**';
}
@@ -373,7 +370,7 @@ final class DibiTranslator extends DibiObject
$value = (int) $value; // timestamp
} elseif (is_string($value)) {
$value = class_exists('DateTime', FALSE) ? new DateTime($value) : strtotime($value);
$value = new DateTime($value);
}
return $this->driver->escape($value, $modifier);
}
@@ -429,9 +426,6 @@ final class DibiTranslator extends DibiObject
} elseif ($value === NULL) {
return 'NULL';
} elseif ($value instanceof IDibiVariable) {
return $value->toSql($this, NULL);
} elseif ($value instanceof DateTime) {
return $this->driver->escape($value, dibi::DATETIME);

View File

@@ -1,48 +0,0 @@
<?php
/**
* dibi - tiny'n'smart database abstraction layer
* ----------------------------------------------
*
* Copyright (c) 2005, 2009 David Grudl (http://davidgrudl.com)
*
* 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://dibiphp.com
*
* @copyright Copyright (c) 2005, 2009 David Grudl
* @license http://dibiphp.com/license dibi license
* @link http://dibiphp.com
* @package dibi
*/
/**
* Default implemenation of IDibiVariable.
* @package dibi
*/
class DibiVariable extends DibiObject implements IDibiVariable
{
/** @var mixed */
public $value;
/** @var string */
public $modifier;
public function __construct($value, $modifier)
{
$this->value = $value;
$this->modifier = $modifier;
}
public function toSql(DibiTranslator $translator, $modifier)
{
return $translator->formatValue($this->value, $this->modifier);
}
}

View File

@@ -19,25 +19,6 @@
/**
* Interface for user variable, used for generating SQL.
* @package dibi
*/
interface IDibiVariable
{
/**
* Format for SQL.
* @param DibiTranslator
* @param string optional modifier
* @return string SQL code
*/
function toSql(DibiTranslator $translator, $modifier);
}
/**
* Provides an interface between a dataset and data-aware components.
* @package dibi