Пример #1
0
 public function updateView()
 {
     try {
         $dbObj = DB::update($this->TABLE)->set(array("Views" => $this->Views + 1))->where('ID', $this->ID);
         $dbResult = $dbObj->execute();
     } catch (\Exception $e) {
     }
 }
Пример #2
0
 public static function update($post_object, $id)
 {
     $dbResult = DB::update(self::$TABLE)->set($post_object)->where('ID', $id)->execute();
     $error = array();
     if ($dbResult == 1) {
         $error['ErrorCode'] = 1;
         $error['ErrorMsg'] = 'Success with PostID = ' . $id;
     } else {
         $error['ErrorCode'] = -1;
         $error['ErrorMsg'] = 'Unknow error';
     }
     return $error;
 }
Пример #3
0
 public static function update($id, $info)
 {
     $update_field = Staff::$INSERT_FIELD;
     $update_data = array();
     foreach ($update_field as $item) {
         $update_data[$item] = $info[$item];
     }
     $dbResult = DB::update(Staff::$TABLE)->set($update_data)->where('ID', $id)->execute();
     if ($dbResult > 0) {
         // Success
     } else {
         // Failt
     }
 }
Пример #4
0
 public function update($storyObj, $id)
 {
     try {
         $dbObj = DB::update($this->TABLE)->set($storyObj)->where('ID', $id);
         $dbResult = $dbObj->execute();
         if ($dbResult != 1) {
             return null;
         } else {
             return $dbResult;
         }
     } catch (\Exception $e) {
         CError::dbLog($e);
         return null;
     }
 }
Пример #5
0
 /**
  * @author Thuanth6589 <*****@*****.**>
  * save multi post
  * @param array $data
  * @param $m_media_id
  * @return bool
  */
 public function save_multi_post($data = array(), $m_media_id)
 {
     $data = $this->set_array_post($data);
     $data_update = array();
     $data_insert = array();
     foreach ($data as $k => $v) {
         foreach ($v as $key => $val) {
             if (in_array($key, self::$_properties)) {
                 $v[$key] = trim($val) != '' ? trim($val) : null;
             }
         }
         if (isset($v['post_id'])) {
             $data_update[] = $v;
         } else {
             $data_insert[] = $v;
         }
     }
     if (!empty($data_insert)) {
         $query = DB::insert('m_post')->columns(array('name', 'count', 'price', 'note', 'm_media_id', 'created_at', 'updated_at'));
         foreach ($data_insert as $k => $v) {
             $query->values(array($v['name'], $v['count'], $v['price'], $v['note'], $m_media_id, date('Y-m-d H:i:s', time()), date('Y-m-d H:i:s', time())));
         }
         $result = $query->execute();
         if (!isset($result[1]) || $result[1] != count($data_insert)) {
             return false;
         }
     }
     if (!empty($data_update)) {
         foreach ($data_update as $k => $v) {
             $query = \Fuel\Core\DB::update('m_post');
             $query->set(array('name' => $v['name'], 'count' => $v['count'], 'price' => $v['price'], 'note' => $v['note'], 'updated_at' => date('Y-m-d H:i:s', time())));
             $query->where('post_id', $v['post_id']);
             $result = $query->execute();
             if (!$result) {
                 return false;
             }
         }
     }
     return true;
 }