summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Cornutt <enygma@phpdeveloper.org>2015-01-19 06:13:32 -0600
committerChris Cornutt <enygma@phpdeveloper.org>2015-01-19 06:13:32 -0600
commita7e38e180ada2752016ebc59f043df45cb540cfe (patch)
treed4e6424332cf3e93bfd14860cf0085928b17499a /src
parentf603aa73081383a5806802bff92db6fe7b7f4970 (diff)
downloadgatekeeper-a7e38e180ada2752016ebc59f043df45cb540cfe.zip
gatekeeper-a7e38e180ada2752016ebc59f043df45cb540cfe.tar.gz
gatekeeper-a7e38e180ada2752016ebc59f043df45cb540cfe.tar.bz2
adding option to force return as multiple or single
Diffstat (limited to 'src')
-rw-r--r--src/Psecio/Gatekeeper/DataSource/Mysql.php6
-rw-r--r--src/Psecio/Gatekeeper/Gatekeeper.php2
2 files changed, 5 insertions, 3 deletions
diff --git a/src/Psecio/Gatekeeper/DataSource/Mysql.php b/src/Psecio/Gatekeeper/DataSource/Mysql.php
index 645055f..b3d043d 100644
--- a/src/Psecio/Gatekeeper/DataSource/Mysql.php
+++ b/src/Psecio/Gatekeeper/DataSource/Mysql.php
@@ -184,10 +184,12 @@ class Mysql extends \Psecio\Gatekeeper\DataSource
* Find records matching the "where" data given
* All "where" options are appended via "and"
*
+ * @param \Modler\Model $model Model instance
* @param array $where Data to use in "where" statement
+ * @param boolean $multiple Force return of single/multiple
* @return array Fetched data
*/
- public function find(\Modler\Model $model, array $where = array())
+ public function find(\Modler\Model $model, array $where = array(), $multiple = false)
{
$properties = $model->getProperties();
list($columns, $bind) = $this->setup($where);
@@ -207,7 +209,7 @@ class Mysql extends \Psecio\Gatekeeper\DataSource
$result = $this->fetch($sql, $where);
- if ($result !== false && count($result) == 1) {
+ if ($result !== false && count($result) == 1 && $multiple === false) {
$model->load($result[0]);
return $model;
} else {
diff --git a/src/Psecio/Gatekeeper/Gatekeeper.php b/src/Psecio/Gatekeeper/Gatekeeper.php
index 0ce45a3..85c78fa 100644
--- a/src/Psecio/Gatekeeper/Gatekeeper.php
+++ b/src/Psecio/Gatekeeper/Gatekeeper.php
@@ -327,7 +327,7 @@ class Gatekeeper
}
$model = self::modelFactory($model.'Model');
$collection = new $collectionNs(self::$datasource);
- $collection = self::$datasource->find($model, $data);
+ $collection = self::$datasource->find($model, $data, true);
return $collection;
}