getInstance() returns null if object was not found in database

This commit is contained in:
Uwe Steinmann 2017-12-22 13:02:14 +01:00
parent 3330085f51
commit 97946893ee
2 changed files with 7 additions and 5 deletions

View File

@ -58,14 +58,15 @@ class SeedDMS_Core_Group { /* {{{ */
} /* }}} */
/**
* Create an instance of a group object
* Return an instance of a group object
*
* @param string|integer $id Id, name of group, depending
* on the 3rd parameter.
* @param object $dms instance of dms
* @param string $by search by group name if set to 'name'.
* Search by Id of group if left empty.
* @return object instance of class SeedDMS_Core_Group
* @return object instance of class SeedDMS_Core_Group if group was found, null
* if group was not found, false in case of error
*/
public static function getInstance($id, $dms, $by='') { /* {{{ */
$db = $dms->getDB();
@ -82,7 +83,7 @@ class SeedDMS_Core_Group { /* {{{ */
if (is_bool($resArr) && $resArr == false)
return false;
else if (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-)
return false;
return null;
$resArr = $resArr[0];

View File

@ -163,7 +163,8 @@ class SeedDMS_Core_User { /* {{{ */
* will check for the 4th paramater and also filter by email. If this
* parameter is left empty, the user will be search by its Id.
* @param string $email optional email address if searching for name
* @return object instance of class SeedDMS_Core_User
* @return object instance of class SeedDMS_Core_User if user was found, null
* if user was not found, false in case of error
*/
public static function getInstance($id, $dms, $by='', $email='') { /* {{{ */
$db = $dms->getDB();
@ -183,7 +184,7 @@ class SeedDMS_Core_User { /* {{{ */
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false) return false;
if (count($resArr) != 1) return false;
if (count($resArr) != 1) return null;
$resArr = $resArr[0];