简体   繁体   中英

PDO insert statement not work

I have problem with INSERT query. It returns false and doesn't inserting anything into the database.

I'm connected to database and other delete and update queries are working, but insert doesn't.

Here is my function which prepares and runs the insert query:

    Autoloader::Load('HandleDB/InsertDB');
    $insert = new InsertDB();
    echo "<p>data:</p>";
    var_dump($data);
    echo "<p>prepare</p>";
    var_dump($statment = $this->db->prepare($insert->Run($tableName,   $data)));
    echo "<p>prepare execute</p>";
    var_dump($insert->PrepareExecute($data));
    echo "<p>execute result:</p>";
    var_dump($statment->execute($insert->PrepareExecute($data)));

The result of this function is:

data:
array(3) { ["imie"]=> string(4) "user" ["login"]=> string(9) "loginname" ["password"]=> string(4) "pass" }
prepare

object(PDOStatement)#9 (1) { ["queryString"]=> string(80) "INSERT INTO uzytkownik (imie, login, password) VALUES (:imie, :login, :password)" }
prepare execute

array(3) { ["imie"]=> string(4) "user" ["login"]=> string(9) "loginname" ["password"]=> string(4) "pass" }
execute result:

bool(false)

using MVC model with PDO, files written by my classmate. Other files and functions and queries works fine. Just this one.

This function gets $data as parameters from form.

Table structure:

Table name "uzytkownik":

  • ID (autoincrement)
  • imie
  • login
  • haslo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM