Example #1
0
 /**
  * Получает user_id у объявления по advert_id.
  * 
  * @param int $user_id
  * @return int
  */
 public static function getUserIdByAdvertId($id)
 {
     $user_id = 0;
     $result = NULL;
     try {
         $result = DB::select('user_id')->from('adverts')->where('id', '=', $id)->and_where('deleted', '=', '0')->execute();
     } catch (Database_Exception $e) {
         if (is_null(self::$controller)) {
             throw $e;
         } else {
             self::$controller->action_server_error();
         }
         return;
     }
     if (!is_null($result)) {
         $user_id = $result->get('user_id');
     } else {
         self::$controller->action_no_advert();
         return;
     }
     return $user_id;
 }