mirror of
https://github.com/dg/dibi.git
synced 2025-08-07 06:36:44 +02:00
DibiResult is configured via items 'detectTypes' and 'formatDateTime' in 'result' subarray; removed RESULT_DETECT_TYPES & RESULT_DATE_TIME
This commit is contained in:
@@ -167,13 +167,7 @@ class dibi
|
|||||||
const REVISION = '$WCREV$ released on $WCDATE$';
|
const REVISION = '$WCREV$ released on $WCDATE$';
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
/**#@+
|
|
||||||
* Configuration options
|
|
||||||
*/
|
|
||||||
const RESULT_DETECT_TYPES = 'resultDetectTypes';
|
|
||||||
const RESULT_DATE_TIME = 'resultDateTime';
|
|
||||||
const ASC = 'ASC', DESC = 'DESC';
|
const ASC = 'ASC', DESC = 'DESC';
|
||||||
/**#@-*/
|
|
||||||
|
|
||||||
/** @var DibiConnection[] Connection registry storage for DibiConnection objects */
|
/** @var DibiConnection[] Connection registry storage for DibiConnection objects */
|
||||||
private static $registry = array();
|
private static $registry = array();
|
||||||
|
@@ -55,7 +55,11 @@ class DibiConnection extends DibiObject
|
|||||||
parse_str($config, $config);
|
parse_str($config, $config);
|
||||||
|
|
||||||
} elseif ($config instanceof Traversable) {
|
} elseif ($config instanceof Traversable) {
|
||||||
$config = iterator_to_array($config);
|
$tmp = array();
|
||||||
|
foreach ($config as $key => $val) {
|
||||||
|
$tmp[$key] = $val instanceof Traversable ? iterator_to_array($val) : $val;
|
||||||
|
}
|
||||||
|
$config = $tmp;
|
||||||
|
|
||||||
} elseif (!is_array($config)) {
|
} elseif (!is_array($config)) {
|
||||||
throw new InvalidArgumentException('Configuration must be array, string or object.');
|
throw new InvalidArgumentException('Configuration must be array, string or object.');
|
||||||
@@ -64,6 +68,8 @@ class DibiConnection extends DibiObject
|
|||||||
self::alias($config, 'username', 'user');
|
self::alias($config, 'username', 'user');
|
||||||
self::alias($config, 'password', 'pass');
|
self::alias($config, 'password', 'pass');
|
||||||
self::alias($config, 'host', 'hostname');
|
self::alias($config, 'host', 'hostname');
|
||||||
|
self::alias($config, 'result|detectTypes', 'resultDetectTypes'); // back compatibility
|
||||||
|
self::alias($config, 'result|formatDateTime', 'resultDateTime');
|
||||||
|
|
||||||
if (!isset($config['driver'])) {
|
if (!isset($config['driver'])) {
|
||||||
$config['driver'] = dibi::$defaultDriver;
|
$config['driver'] = dibi::$defaultDriver;
|
||||||
@@ -324,7 +330,7 @@ class DibiConnection extends DibiObject
|
|||||||
|
|
||||||
dibi::$sql = $sql;
|
dibi::$sql = $sql;
|
||||||
if ($res = $this->driver->query($sql)) { // intentionally =
|
if ($res = $this->driver->query($sql)) { // intentionally =
|
||||||
$res = new DibiResult($res, $this->config);
|
$res = new DibiResult($res, $this->config['result']);
|
||||||
} else {
|
} else {
|
||||||
$res = $this->driver->getAffectedRows();
|
$res = $this->driver->getAffectedRows();
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,10 @@
|
|||||||
* unset($result);
|
* unset($result);
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
|
* Result options:
|
||||||
|
* - 'detectTypes' - whether call automatically detectTypes()
|
||||||
|
* - 'formatDateTime' - how to format datetime
|
||||||
|
*
|
||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi
|
* @package dibi
|
||||||
*
|
*
|
||||||
@@ -68,12 +72,12 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
|
|
||||||
if (!empty($config[dibi::RESULT_DETECT_TYPES])) {
|
if (!empty($config['detectTypes'])) {
|
||||||
$this->detectTypes();
|
$this->detectTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($config[dibi::RESULT_DATE_TIME])) {
|
if (!empty($config['formatDateTime'])) {
|
||||||
$this->dateFormat = is_string($config[dibi::RESULT_DATE_TIME]) ? $config[dibi::RESULT_DATE_TIME] : '';
|
$this->dateFormat = is_string($config['formatDateTime']) ? $config['formatDateTime'] : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user