Created
April 10, 2012 08:10
-
-
Save nibsirahsieu/2349253 to your computer and use it in GitHub Desktop.
Revisions
-
nibsirahsieu revised this gist
Apr 10, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,6 +37,7 @@ class myPropelOnDemandFormatter extends \PropelOnDemandFormatter return $result; } //taken from PropelSimpleArrayFormatter public function getStructuredArrayFromRow($row) { $columnNames = array_keys($this->getAsColumns ()); -
nibsirahsieu created this gist
Apr 10, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ <?php namespace Egov\DeliveryBundle\Util; class myPropelOnDemandFormatter extends \PropelOnDemandFormatter { protected $isSelect = false; public function init(\ModelCriteria $criteria) { parent::init($criteria); if (!is_null($criteria->getSelect())) { $this->isSelect = true; } return $this; } public function isObjectFormatter() { return !$this->isSelect; } public function getAllObjectsFromRow($row) { $result = null; if ($this->isSelect) { if ($object = $this->getStructuredArrayFromRow($row)) { $result = $object; } } else { $result = parent::getAllObjectsFromRow($row); } return $result; } public function getStructuredArrayFromRow($row) { $columnNames = array_keys($this->getAsColumns ()); if (count($columnNames) > 1 && count($row) > 1) { $finalRow = array(); foreach ($row as $index => $value) { $finalRow[str_replace('"', '', $columnNames[$index])] = $value; } } else { $finalRow = $row[0]; } return $finalRow; } }