Пример #1
0
 /**
  * Find and return records from database by param
  *
  * @access public
  * @static
  *
  * @param string $record
  *
  * @return array|ActiveRecord
  * @throws \Framework\Exception\DataBaseException
  * @throws \Framework\Exception\ServiceException
  */
 public static function find($record)
 {
     if (!isset(static::$database)) {
         self::$database = Service::get('dataBase');
     }
     if ($record == static::ALL_RECORDS) {
         $allRecords = self::$database->selectAll(static::getTable());
         $posts = array();
         foreach ($allRecords as $rec) {
             $posts[] = new static($rec);
         }
         return $posts;
     } else {
         $record = self::$database->select(static::getTable(), array('*'), array('id' => $record));
         return new static($record);
     }
 }