PDO : insert 3 rows instead in mysql when i insert just 1 row

Hamidreza Ghaffari

I use PDO in my php framework (flight) and i have a ridiculous problem. When i insert 1 row into the mysql i saw 3 rows inserted .

Flight::db()->query("INSERT INTO `menu_item`(`order`, `menu_cat_id`) VALUES (22,1)");

This is My whole code :

<?php
require 'flight/Flight.php';

Flight::register('db', 'PDO', array('mysql:host=localhost;port=3306;dbname=deliman', 'root', ''), function($db) {
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
        $db->exec("SET NAMES 'utf8';");
        $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
});

Flight::route('/menu/item/new', function(){
        //$conn = Flight::db();
        $data = Flight::db()->query("INSERT INTO `menu_item`(`order`, `menu_cat_id`) VALUES (22,1)");

        //SET @maxOrder := (SELECT `order` FROM `menu_item` WHERE `menu_cat_id` = 1 ORDER BY `order` DESC LIMIT 1) +1 ;
        //SELECT LAST_INSERT_ID() AS id;
        echo 'a';
    });


Flight::start();
?>
Hamidreza Ghaffari

i find my answer in this post . pdo insert two rows when I wanna insert only one

So when i test in my browser , it send multiple request and every time my code running . That's it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PDO - Insert new row when duplicate detected based on 3 values

From Dev

PDO Prepared statement insert 1 instead of string

From Dev

how I can insert just one row?

From Dev

When I INSERT multiple rows into a MySQL table, will the ids be increment by 1 everytime?

From Dev

INSERT INTO WITH SELECT resulting in multiple rows inserted instead of just one

From Dev

INSERT INTO WITH SELECT resulting in multiple rows inserted instead of just one

From Dev

Insert different values in array in MySQL in the same columns with just 1 insert

From Dev

Converting MySql Insert To PDO

From Dev

INSERT INTO array with MySQL and PDO

From Dev

PDO insert BindParam mysql

From Dev

What is the best way to insert multiple rows in PHP PDO MYSQL?

From Dev

how to Insert multiple arrays with multiple rows into MySQL using PHP PDO

From Dev

PDO insert into inserting two rows

From Dev

insert into using same row(same primary key) mysql php pdo

From Dev

insert into using same row(same primary key) mysql php pdo

From Dev

Mysql: Select after Insert failing to find rows just inserted

From Dev

query insert only one row instead multiple rows

From Dev

Pdo multiple row insert issue

From Dev

PHP output script just putting 'row' instead of mysql rows?

From Dev

How do I insert rows in Mysql if row doesn't exist with same value

From Dev

MYSQL Insert Where Not Exists with PDO

From Dev

Using mysql insert with implode in PDO

From Dev

Confirm record INSERT with PDO and MySQL

From Dev

Insert cookies and date pdo mysql

From Dev

MySQL insert category rows

From Dev

How do I insert two values in mysql with just one select?

From Dev

MySQL insert row with date

From Dev

Mysql row insert time

From Dev

Insert row PHP to MySQL

Related Related

  1. 1

    PDO - Insert new row when duplicate detected based on 3 values

  2. 2

    PDO Prepared statement insert 1 instead of string

  3. 3

    how I can insert just one row?

  4. 4

    When I INSERT multiple rows into a MySQL table, will the ids be increment by 1 everytime?

  5. 5

    INSERT INTO WITH SELECT resulting in multiple rows inserted instead of just one

  6. 6

    INSERT INTO WITH SELECT resulting in multiple rows inserted instead of just one

  7. 7

    Insert different values in array in MySQL in the same columns with just 1 insert

  8. 8

    Converting MySql Insert To PDO

  9. 9

    INSERT INTO array with MySQL and PDO

  10. 10

    PDO insert BindParam mysql

  11. 11

    What is the best way to insert multiple rows in PHP PDO MYSQL?

  12. 12

    how to Insert multiple arrays with multiple rows into MySQL using PHP PDO

  13. 13

    PDO insert into inserting two rows

  14. 14

    insert into using same row(same primary key) mysql php pdo

  15. 15

    insert into using same row(same primary key) mysql php pdo

  16. 16

    Mysql: Select after Insert failing to find rows just inserted

  17. 17

    query insert only one row instead multiple rows

  18. 18

    Pdo multiple row insert issue

  19. 19

    PHP output script just putting 'row' instead of mysql rows?

  20. 20

    How do I insert rows in Mysql if row doesn't exist with same value

  21. 21

    MYSQL Insert Where Not Exists with PDO

  22. 22

    Using mysql insert with implode in PDO

  23. 23

    Confirm record INSERT with PDO and MySQL

  24. 24

    Insert cookies and date pdo mysql

  25. 25

    MySQL insert category rows

  26. 26

    How do I insert two values in mysql with just one select?

  27. 27

    MySQL insert row with date

  28. 28

    Mysql row insert time

  29. 29

    Insert row PHP to MySQL

HotTag

Archive