getkirby-v2 / toolkit

This is the deprecated toolkit for Kirby v2.
http://getkirby.com
81 stars 50 forks source link

Database insert works only 1st time in 2.3.0 #179

Closed ghost closed 8 years ago

ghost commented 8 years ago

If you try to insert rows into a database (MySQL and SQLite) like so:

$users = $database->table('users');
for ($i = 0; $i < 5; $i++) {
  $users->insert(array('username' => 'john'));
}

only 1 row is inserted. There are no exceptions or errors. If, however, you change the insert statement within the loop to reference the table directly:

for ($i = 0; $i < 5; $i++) {
  $database->table('users')->insert(array('username' => 'john'));
}

then 5 rows are inserted as expected.

This behavior was introduced with Kirby 2.3.0 (2.2.3 has no such problem). Is this intended behavior?

lukasbestle commented 8 years ago

No, this is not intended. Please check if #171 fixes this issue for you, that would help a lot.

ghost commented 8 years ago

Yes, thank you! #171 fixes this.