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

后端 未结 3 1196
被撕碎了的回忆
被撕碎了的回忆 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:32

    The problem doesn't seem to be involved on the surface of the code you posted however by placing your prepare() statement in a try-catch block, you'll be able to find out if its either an issue in your SQL query or PHP code....

    try {
         //...
         $q = $this->_db->prepare('UPDATE posts SET title = :title, featuredImg = :featuredImg, content = :content, author = :author, date = :date, header = :header WHERE id = :id');
         //...
         $q->execute();
    } catch (Exception $e) {
         echo "Problem happened: " . $e->getMessage() 
    }
    

    This way you can get more then a NULL as a response.

提交回复
热议问题