mirror of
https://github.com/dg/dibi.git
synced 2025-08-12 00:54:11 +02:00
* better datetime converting in DibiResult (see http://forum.dibiphp.com/viewtopic.php?pid=2331)
* added support for Nette_Debug * renamed NObject -> Nette_Object (Nette::Object in PHP 5.3)
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
class DibiConnection extends NObject
|
||||
class DibiConnection extends Nette_Object
|
||||
{
|
||||
/**
|
||||
* Current connection configuration.
|
||||
@@ -58,7 +58,7 @@ class DibiConnection extends NObject
|
||||
/**
|
||||
* Creates object and (optionally) connects to a database.
|
||||
*
|
||||
* @param array|string|IMap connection parameters
|
||||
* @param array|string|Nette_Collections_IMap connection parameters
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function __construct($config)
|
||||
@@ -67,7 +67,7 @@ class DibiConnection extends NObject
|
||||
if (is_string($config)) {
|
||||
parse_str($config, $config);
|
||||
|
||||
} elseif ($config instanceof IMap) {
|
||||
} elseif ($config instanceof Nette_Collections_IMap) {
|
||||
$config = $config->toArray();
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
class DibiDataSource extends NObject implements IDataSource
|
||||
class DibiDataSource extends Nette_Object implements IDataSource
|
||||
{
|
||||
/** @var DibiConnection */
|
||||
private $connection;
|
||||
|
@@ -42,7 +42,7 @@ class DibiException extends Exception
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
class DibiDriverException extends DibiException implements IDebuggable
|
||||
class DibiDriverException extends DibiException implements Nette_IDebuggable
|
||||
{
|
||||
/** @var string */
|
||||
private static $errorMsg;
|
||||
@@ -87,6 +87,27 @@ class DibiDriverException extends DibiException implements IDebuggable
|
||||
|
||||
|
||||
|
||||
/********************* interface Nette_IDebuggable ****************d*g**/
|
||||
|
||||
|
||||
/**
|
||||
* Returns custom panels.
|
||||
* @return array
|
||||
*/
|
||||
public function getPanels()
|
||||
{
|
||||
$panels = array();
|
||||
if ($this->sql !== NULL) {
|
||||
$panels['SQL'] = array(
|
||||
'expanded' => TRUE,
|
||||
'content' => dibi::dump($this->sql, TRUE),
|
||||
);
|
||||
}
|
||||
return $panels;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* error catching ****************d*g**/
|
||||
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
final class DibiLogger extends NObject
|
||||
final class DibiLogger extends Nette_Object
|
||||
{
|
||||
/** @var string Name of the file where SQL errors should be logged */
|
||||
private $file;
|
||||
|
@@ -41,7 +41,7 @@
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
class DibiResult extends NObject implements IDataSource
|
||||
class DibiResult extends Nette_Object implements IDataSource
|
||||
{
|
||||
/**
|
||||
* IDibiDriver.
|
||||
@@ -240,7 +240,7 @@ class DibiResult extends NObject implements IDataSource
|
||||
if ($this->xlat !== NULL) {
|
||||
foreach ($this->xlat as $col => $type) {
|
||||
if (isset($row[$col])) {
|
||||
$row[$col] = $this->convert($row[$col], $type);
|
||||
$row[$col] = $this->convert($row[$col], $type[0], $type[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,8 @@ class DibiResult extends NObject implements IDataSource
|
||||
// types-converting?
|
||||
$key = key($row);
|
||||
if (isset($this->xlat[$key])) {
|
||||
return $this->convert($value, $this->xlat[$key]);
|
||||
$type = $this->xlat[$key];
|
||||
return $this->convert($value, $type[0], $type[1]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -447,14 +448,9 @@ class DibiResult extends NObject implements IDataSource
|
||||
|
||||
|
||||
|
||||
final public function setType($col, $type = NULL)
|
||||
final public function setType($col, $type = NULL, $format = NULL)
|
||||
{
|
||||
if (is_array($col)) {
|
||||
$this->xlat = $col;
|
||||
|
||||
} else {
|
||||
$this->xlat[$col] = $type;
|
||||
}
|
||||
$this->xlat[$col] = array($type, $format);
|
||||
}
|
||||
|
||||
|
||||
@@ -466,7 +462,7 @@ class DibiResult extends NObject implements IDataSource
|
||||
|
||||
|
||||
|
||||
final public function convert($value, $type)
|
||||
final public function convert($value, $type, $format = NULL)
|
||||
{
|
||||
if ($value === NULL || $value === FALSE) {
|
||||
return $value;
|
||||
@@ -478,7 +474,7 @@ class DibiResult extends NObject implements IDataSource
|
||||
}
|
||||
|
||||
if ($type === dibi::FIELD_DATE || $type === dibi::FIELD_DATETIME) {
|
||||
return strtotime($value);
|
||||
return $format === NULL ? strtotime($value) : date($format, strtotime($value));
|
||||
}
|
||||
|
||||
if ($type === dibi::FIELD_BOOL) {
|
||||
|
@@ -26,7 +26,7 @@
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
abstract class DibiTable extends NObject
|
||||
abstract class DibiTable extends Nette_Object
|
||||
{
|
||||
/** @var string primary key mask */
|
||||
public static $primaryMask = 'id';
|
||||
|
@@ -27,7 +27,7 @@
|
||||
* @package dibi
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
final class DibiTranslator extends NObject
|
||||
final class DibiTranslator extends Nette_Object
|
||||
{
|
||||
/** @var string */
|
||||
public $sql;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
* Default implemenation of IDibiVariable.
|
||||
* @package dibi
|
||||
*/
|
||||
class DibiVariable extends NObject implements IDibiVariable
|
||||
class DibiVariable extends Nette_Object implements IDibiVariable
|
||||
{
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
|
Reference in New Issue
Block a user