Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 21c4581

Browse files
author
Michael Grauer
committed
BUG: refs #258. Fixed findBy method to work when called from a module model.
1 parent 8f85746 commit 21c4581

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

core/models/MIDASModel.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,33 @@ public function findBy($var, $value)
238238
}
239239
$rowset = $this->database->findBy($var, $value);
240240
$return = array();
241-
foreach($rowset as $row)
241+
242+
// if there are any rows, set the daoName
243+
if(isset($rowset) && sizeof($rowset) > 0)
242244
{
243-
$daoName = ucfirst($this->_name);
244245
if(isset($this->_daoName))
245246
{
246247
$daoName = substr($this->_daoName, 0, strlen($this->_daoName)-3);
247248
}
249+
else
250+
{
251+
// can't just convert the name to dao name, in case it is in a module
252+
if(isset($this->moduleName))
253+
{
254+
// we want to split the string, expecting 2 parts, module_model
255+
// just use the model name for the dao
256+
$parts = explode('_', $this->_name);
257+
$daoName = ucfirst($parts[1]);
258+
}
259+
else
260+
{
261+
// if no module, just upper case the model name
262+
$daoName = ucfirst($this->_name);
263+
}
264+
}
265+
}
266+
foreach($rowset as $row)
267+
{
248268
$tmpDao = $this->initDao($daoName, $row, $module);
249269
$return[] = $tmpDao;
250270
unset($tmpDao);

0 commit comments

Comments
 (0)