コード例 #1
0
 public function create_notification($title, $message, $code = NULL, $category = NULL, $update = FALSE)
 {
     $category = is_null($category) ? 'Message' : $category;
     $code = is_null($code) ? 'ionize' : $code;
     $done = false;
     $where = array('title' => $title, 'category' => $category, 'code' => $code, 'read' => '0');
     $data = array('date_creation' => date('Y-m-d H:i:s'), 'content' => $message);
     if ($update) {
         $existing = parent::get_row_array($where);
         if (!empty($existing)) {
             parent::update($where, $data);
             $done = TRUE;
         }
     }
     if (!$done) {
         $data = array_merge($where, $data);
         parent::insert($data);
     }
 }