public function findByWithUser($names, $ids) { if (!is_array($ids)) { $ids = array($ids); } if (!is_array($names)) { $names = array($names); } $c = static::getModelName(); $sth = ServiceDb::getInstance()->prepare(' select `' . static::getTableName() . '`.*, `user`.* from `' . static::getTableName() . '` left join `user` on `user`.`id`=`' . static::getTableName() . '`.`user_id` where `' . implode('`=? and `', $names) . '`=?'); $sth->execute($ids); $arr = array(); foreach ($sth->fetchAll() as $data) { if ($data['id'] == ServiceAuth::getInstance()->getUser()->getId()) { continue; } $a = new ModelUser(); $a->hydrate($data); $b = new $c(); $b->hydrate($data); $a->setProfile($b); $arr[] = $a; } return $arr; }