Exemplo n.º 1
0
 function FindByName($name = "")
 {
     if ($name == "") {
         return;
     }
     return MyActiveRecord::FindFirst('Keywords', "(name like '{$name}')");
     //return array_shift(MyActiveRecord::FindBySql('Keywords', "SELECT );
 }
Exemplo n.º 2
0
 function get_thumb()
 {
     return MyActiveRecord::FindFirst('Photos', "gallery_id = {$this->id}", "id ASC");
 }
 /**
  * Returns an object of class strClass found in database with a specific
  * integer ID. An array of integers can be passed in order to retrieve an
  * array of objects with matching IDs
  * eg:
  * <code>
  * $car = MyActiveRecord::FindById(15);
  * $cars = MyActiveRecord::FindById(3, 5, 13);
  * </code>
  *
  * @static
  * @param string  strClass  the name of the class for which you want objects
  * @param mixed mxdID integer or array of integers
  * @return  mixed object, or array of objects
  */
 static function FindById($strClass, $mxdID)
 {
     if (is_array($mxdID)) {
         $idlist = implode(', ', $mxdID);
         return MyActiveRecord::FindAll($strClass, "`id` IN ({$idlist})");
     } else {
         $id = intval($mxdID);
         return MyActiveRecord::FindFirst($strClass, array('id' => $id));
     }
 }
Exemplo n.º 4
0
 function FindBySlug($slug = "")
 {
     $slug = mysql_real_escape_string($slug, MyActiveRecord::Connection());
     return MyActiveRecord::FindFirst('Chunks', "slug = '{$slug}'");
 }
Exemplo n.º 5
0
 function FindByName($name)
 {
     return MyActiveRecord::FindFirst('Product', "name='{$name}'");
 }
Exemplo n.º 6
0
 function FindByName($name = "")
 {
     $name = mysql_real_escape_string($name, MyActiveRecord::Connection());
     return MyActiveRecord::FindFirst('Videos', "slug = '{$name}'");
 }
Exemplo n.º 7
0
 static function FindFirst($strClass, $extend = false, $strWhere = null, $strOrderBy = null)
 {
     if (!AppModel::_smartLoadModel($strClass)) {
         return false;
     }
     $strOrderBy = get_default($strOrderBy, AppModel::Create($strClass)->order_by);
     if ($object = parent::FindFirst($strClass, $strWhere, $strOrderBy)) {
         $objects = array($object);
         if ($extend) {
             AppModel::AddAllRelated($objects);
         }
         return $objects[0];
     } else {
         return false;
     }
 }