public static function insertCard($card_id, $name, $desc, $due, $list_id) { $update = true; $model = Cards::getCardbyCardID($card_id); if ($model === null) { $model = new Cards(); $update = false; } $model->card_id = $card_id; $model->name = $name; $model->desc = $desc; $model->due = $due; $model->list_id = $list_id; if ($update) { if ($model->save()) { } } else { $model->insert(); } }