{"action":"created","issue":{"url":"https://api.github.com/repos/getkirby/toolkit/issues/169","repository_url":"https://api.github.com/repos/getkirby/toolkit","labels_url":"https://api.github.com/repos/getkirby/toolkit/issues/169/labels{/name}","comments_url":"https://api.github.com/repos/getkirby/toolkit/issues/169/comments","events_url":"https://api.github.com/repos/getkirby/toolkit/issues/169/events","html_url":"https://github.com/getkirby/toolkit/issues/169","id":156590778,"number":169,"title":"Query class: Preserving bindings between database calls in 2.3.0","user":{"login":"ivinteractive","id":8458490,"avatar_url":"https://avatars.githubusercontent.com/u/8458490?v=3","gravatar_id":"","url":"https://api.github.com/users/ivinteractive","html_url":"https://github.com/ivinteractive","followers_url":"https://api.github.com/users/ivinteractive/followers","following_url":"https://api.github.com/users/ivinteractive/following{/other_user}","gists_url":"https://api.github.com/users/ivinteractive/gists{/gist_id}","starred_url":"https://api.github.com/users/ivinteractive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivinteractive/subscriptions","organizations_url":"https://api.github.com/users/ivinteractive/orgs","repos_url":"https://api.github.com/users/ivinteractive/repos","events_url":"https://api.github.com/users/ivinteractive/events{/privacy}","received_events_url":"https://api.github.com/users/ivinteractive/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-24T19:34:15Z","updated_at":"2016-05-25T19:50:21Z","closed_at":null,"body":"We were getting the following error when making multiple calls on the same table:\r\n\r\n```\r\nexception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined'\r\n```\r\n\r\nUsing the `Database\\Query->debug()` method, we could tell that bindings were preserved between database calls. For example:\r\n```\r\n$users = $database->table('users');\r\n$user = $users->where('email','=',$email)->first();\r\n```\r\nAnd later on in the file:\r\n```\r\n$updated = $users->where('id','=',$user->id)->update(array('last_login' => 'NOW()'));\r\n```\r\n\r\nWhen using debug() on that, the amount of bindings would be more than were defined in the update query. We were able to get around that by defining `$users = $database->table('users');` once more above the update query.\r\n\r\nThat could be intended behavior, to require a new instance of the Database\\Query class, but since it wasn't a clean update from 2.2.3 to 2.3.0 and it wasn't listed in the changelog, we thought it might be a bug. Please let us know if that will be changed (clearing out the bindings before setting new ones), or if each database call should use the Database->table() method."},"comment":{"url":"https://api.github.com/repos/getkirby/toolkit/issues/comments/221686724","html_url":"https://github.com/getkirby/toolkit/issues/169#issuecomment-221686724","issue_url":"https://api.github.com/repos/getkirby/toolkit/issues/169","id":221686724,"user":{"login":"ivinteractive","id":8458490,"avatar_url":"https://avatars.githubusercontent.com/u/8458490?v=3","gravatar_id":"","url":"https://api.github.com/users/ivinteractive","html_url":"https://github.com/ivinteractive","followers_url":"https://api.github.com/users/ivinteractive/followers","following_url":"https://api.github.com/users/ivinteractive/following{/other_user}","gists_url":"https://api.github.com/users/ivinteractive/gists{/gist_id}","starred_url":"https://api.github.com/users/ivinteractive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivinteractive/subscriptions","organizations_url":"https://api.github.com/users/ivinteractive/orgs","repos_url":"https://api.github.com/users/ivinteractive/repos","events_url":"https://api.github.com/users/ivinteractive/events{/privacy}","received_events_url":"https://api.github.com/users/ivinteractive/received_events","type":"User","site_admin":false},"created_at":"2016-05-25T19:50:21Z","updated_at":"2016-05-25T19:50:21Z","body":"Sorry to keep updating this, but it was actually closed prematurely. After updating an additional site in a dev environment and checking out the master branch of the updated submodules, we've been experiencing numerous database errors. We've been experiencing errors with the different aggregate() methods and setting table aliases in queries. Please let us know if you need a specific code sample, because that's something we'd be more comfortable sharing privately."}}
{"actor":{"display_login":"ivinteractive"}}