Example #1
0
 public static function insertSession($name, $description, $start_ts, $end_ts, $winner_video_id, $area, $is_active, $img_url)
 {
     if (!is_string($name) || strlen($name) <= 0) {
         return MyUtil::fnOk(false, "Name must be at least 1 character", null);
     } else {
         if (!is_string($start_ts) || !MyUtil::isDateFormat($start_ts)) {
             return MyUtil::fnOk(false, "start_ts must be in yyyy-mm-dd format: {$start_ts}", null);
         } else {
             if (!is_string($end_ts) || !MyUtil::isDateFormat($end_ts)) {
                 return MyUtil::fnOk(false, "end_ts must be in yyyy-mm-dd format: {$end_ts}", null);
             }
         }
     }
     $stm = "INSERT INTO " . self::$table_name . "(name, description, start_ts, end_ts, area, updated_ts, updated_by, is_active, img_url) VALUES (" . "nullIf('" . MyUtil::prepareSqlString(MyUtil::nvl($name, "")) . "', ''), " . "nullIf('" . MyUtil::prepareSqlString(MyUtil::nvl($description, "")) . "', ''), " . "to_timestamp('{$start_ts}','yyyy-mm-dd'), " . "to_timestamp('{$end_ts}','yyyy-mm-dd'), " . "nullIf('" . MyUtil::nvl($area, '') . "',''), " . "CURRENT_TIMESTAMP, " . "'" . $_SESSION['user'] . "', " . "('{$is_active}' = '1'), " . "'{$img_url}'" . ")";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     return MyUtil::fnOk(true, "Session Inserted", $result);
 }