/** * Query by Example. * * Match by attributes of passed example instance and return matched rows as an array of AdminUsersModel instances * * @param PDO $db a PDO Database instance * @param AdminUsersModel $example an example instance defining the conditions. All non-null properties will be considered a constraint, null values will be ignored. * @param boolean $and true if conditions should be and'ed, false if they should be or'ed * @param array $sort array of DSC instances * @return AdminUsersModel[] */ public static function findByExample(PDO $db, AdminUsersModel $example, $and = true, $sort = null) { $exampleValues = $example->toArray(); $filter = array(); foreach ($exampleValues as $fieldId => $value) { if (null !== $value) { $filter[$fieldId] = $value; } } return self::findByFilter($db, $filter, $and, $sort); }