catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

insert method has logical problem #992

Closed afourteene closed 2 years ago

afourteene commented 3 years ago

Information

Describe the Problem when I use insert method data is entered twice. please check your source .

Detail Code `$database = new Medoo([

'type' => 'mysql',
'host' => 'localhost',
'database' => 'databasename',
'username' => 'username',
'password' => 'password'

]); $data = [ ['username' => 'foo', 'userid' => '654654654'], ['username' => 'foo1', 'userid' => '65460000']

]; $database->insert('users', $data);`

medoo

catfan commented 3 years ago

We checked and there is no problem.

You may need to check how your code is called.

Use log() https://medoo.in/api/debug, or debugLogging() https://medoo.in/api/debug to see what queries are executed for the whole project.

logicalor commented 3 years ago

In addition to what @catfan wrote above, a unique index on the username and userid columns would prevent duplicates.

afourteene commented 3 years ago

In addition to what @catfan wrote above, a unique index on the username and userid columns would prevent duplicates.

I know,it's work when use the unique index but sometimes we wouldn't use unique index.

catfan commented 2 years ago

@amirziaee You can use log() or debugLogging() to see what queries are executed. It seems you called the insert() twice.