/** * Logs a message with the Error Log Level * * @param string $msg The log message * @param string $method The method that logged * @return bool If it was successfully logged */ public static function error($msg, $method = null) { $tags = array(__METHOD__); $tags = $method !== null ? array_merge($tags, array($method)) : array(); static::amon($msg, $tags); return parent::write($msg, $method); }
public static function send($option = null) { try { $email = Email::forge(); $email->from(Config::get('email.defaults.from.email'), Config::get('email.defaults.from.name')); $to = $option->to; if (is_string($to)) { $email->to($to); } elseif (is_array($to)) { $email->to(Config::get('email.defaults.from.email'), Config::get('email.defaults.from.name')); $email->bcc($to); } $email->subject(html_entity_decode($option->subject, ENT_QUOTES)); if (!empty($option->attach)) { $email->attach(DOCROOT . $option->attach); } $email->html_body(View::forge('email/' . $option->view, $option->content)); $email->send(); } catch (\EmailSendingFailedException $e) { Log::write('ERROR', $e->getMessage(), 'Send_email'); return false; } catch (\EmailValidationFailedException $e) { Log::write('ERROR', $e->getMessage(), 'Validation_email'); return false; } catch (Exception $e) { Log::write('ERROR', $e->getMessage(), 'Exception'); return false; } return true; }
public static function get_all($option = array()) { try { $category = Model_Category::find('all', array('select' => !empty($option['select']) ? $option['select'] : array(), 'where' => !empty($option['where']) ? $option['where'] : array(), 'order_by' => !empty($option['order_by']) ? $option['order_by'] : array('rank' => 'asc'))); return self::map_category($category); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); } return false; }
public static function get_one($id, $option = array()) { try { $data = Model_GroupFb::find('all', array('select' => !empty($option['all']) ? $option['select'] : array(), 'where' => !empty($option['where']) ? array_merge(array(array('id' => $id)), $option['where']) : array('id' => $id))); return self::map_data($data)[0]; } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); } return false; }
public static function delete($id) { try { $query = Model_Photo::find($id); $query->delete(); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } return true; }
public static function update($data) { try { $data['updated_at'] = date('Y-m-d H:i:s', Date::forge()->get_timestamp()); $query = Model_Config::find(1); $query->set($data); $query->save(); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } return true; }
public static function update($product_id, $category_ids) { try { Model_ProductCategory::query()->where(array('product_id' => $product_id))->delete(); $props = array(); $category_ids = explode(',', $category_ids); foreach ($category_ids as $category_id) { $props[] = array($product_id, $category_id); } return Model_ProductCategory::insert($props); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } }
public static function insert($props) { try { $query = DB::insert(static::$_table_name)->columns(static::$_properties); foreach ($props as $prop) { $query->values($prop); } if ($query->execute()) { return true; } } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } return false; }
public static function get_by_category_ids($category_ids, $offset = _DEFAULT_OFFSET_, $limit = _DEFAULT_LIMIT_) { $ids = join(',', $category_ids); $sql = "\n SELECT `p`.*\n FROM `product_categories` `pc`\n LEFT JOIN `products` `p` ON `pc`.`product_id` = `p`.`id`\n WHERE `pc`.`category_id` IN ({$ids})\n AND `p`.`status` = 1\n GROUP BY `p`.`id`\n ORDER BY `p`.`id` DESC\n LIMIT {$offset}, {$limit}\n "; try { $product = DB::query($sql)->as_object()->execute(); return self::map_product($product); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); } return false; }
public static function delete_user_provider($parent_id) { try { DB::delete('user_providers')->where('parent_id', '=', $parent_id)->execute(); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } return true; }