Can't update or delete dynamically with twig and php oop

后端 未结 3 1191
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 06:47

I\'m learning php oop and I\'m going crazy with this ...

I want to update my database with a form in my website.

I create my model like this :



        
3条回答
  •  [愿得一人]
    2020-12-12 07:25

    Just adding the ID in my Post object and everything is back in order

      $post = new Post([
      'id' => $_POST['id'],
      'title' => $_POST['title'],
      'header' => $_POST['header'],
      'author' => $_POST['author'],
      'date' => date("Y-m-d H:i:s"),
      'content' => $_POST['content'],
      'featuredImg' => $image
    ]);
    

提交回复
热议问题