From d08a5d38564974f87845a428b8fa31003e9099af Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 30 Oct 2008 15:40:17 +0000 Subject: [PATCH] - added DibiResult::setRowClass() --- dibi/libs/DibiResult.php | 34 +++++++++++++++++++++++++++++++++- dibi/libs/DibiTableX.php | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dibi/libs/DibiResult.php b/dibi/libs/DibiResult.php index dc6dcf2f..213dc63e 100644 --- a/dibi/libs/DibiResult.php +++ b/dibi/libs/DibiResult.php @@ -57,6 +57,9 @@ class DibiResult extends DibiObject implements IDataSource /** @var array|FALSE Qualifiy each column name with the table name? */ private $withTables = FALSE; + /** @var string returned object class */ + private $class = 'DibiRow'; + /** @@ -173,6 +176,29 @@ class DibiResult extends DibiObject implements IDataSource + /** + * Set fetched object class. This class should extend the DibiRow class. + * @param string + * @return void + */ + public function setRowClass($class) + { + $this->class = $class; + } + + + + /** + * Returns fetched object class name. + * @return string + */ + public function getRowClass() + { + return $this->class; + } + + + /** * Fetches the row at current position, process optional type conversion. * and moves the internal cursor to the next position @@ -201,7 +227,7 @@ class DibiResult extends DibiObject implements IDataSource } } - return new DibiRow($row, 2); + return new $this->class($row); } @@ -626,4 +652,10 @@ class DibiResult extends DibiObject implements IDataSource */ class DibiRow extends ArrayObject { + + public function __construct($arr) + { + parent::__construct($arr, 2); + } + } diff --git a/dibi/libs/DibiTableX.php b/dibi/libs/DibiTableX.php index 6240b9c5..fade26ca 100644 --- a/dibi/libs/DibiTableX.php +++ b/dibi/libs/DibiTableX.php @@ -292,7 +292,7 @@ abstract class DibiTableX extends DibiObject */ public function createBlank() { - $row = new DibiRow($this->blankRow, 2); + $row = new DibiRow($this->blankRow); $row[$this->primary] = NULL; return $row; }