{"action":"closed","issue":{"url":"https://api.github.com/repos/j4mie/idiorm/issues/299","repository_url":"https://api.github.com/repos/j4mie/idiorm","labels_url":"https://api.github.com/repos/j4mie/idiorm/issues/299/labels{/name}","comments_url":"https://api.github.com/repos/j4mie/idiorm/issues/299/comments","events_url":"https://api.github.com/repos/j4mie/idiorm/issues/299/events","html_url":"https://github.com/j4mie/idiorm/issues/299","id":153245608,"number":299,"title":"odbc:Driver={Microsoft Access Driver (*.mdb)} does not support lastInsertId()","user":{"login":"eduardo-marcolino","id":808889,"avatar_url":"https://avatars.githubusercontent.com/u/808889?v=3","gravatar_id":"","url":"https://api.github.com/users/eduardo-marcolino","html_url":"https://github.com/eduardo-marcolino","followers_url":"https://api.github.com/users/eduardo-marcolino/followers","following_url":"https://api.github.com/users/eduardo-marcolino/following{/other_user}","gists_url":"https://api.github.com/users/eduardo-marcolino/gists{/gist_id}","starred_url":"https://api.github.com/users/eduardo-marcolino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduardo-marcolino/subscriptions","organizations_url":"https://api.github.com/users/eduardo-marcolino/orgs","repos_url":"https://api.github.com/users/eduardo-marcolino/repos","events_url":"https://api.github.com/users/eduardo-marcolino/events{/privacy}","received_events_url":"https://api.github.com/users/eduardo-marcolino/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-05-05T14:37:26Z","updated_at":"2016-08-31T22:50:59Z","closed_at":"2016-08-31T22:50:59Z","body":"I was working with a legacy mdb database and i got this message:\r\n\r\n> \"Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IM001]: Driver does not support this function: driver does not support lastInsertId()' in ..\r\n\r\nHere is my workarond:\r\n\r\nInside  [save()](https://github.com/j4mie/idiorm/blob/master/idiorm.php#L2014) method add this:\r\n\r\n```php\r\nif($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {\r\n  //...\r\n} elseif($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'odbc') {\r\n  self::_execute('SELECT @@IDENTITY AS lastID', array(), $this->_connection_name);\r\n  $statement = self::get_last_statement();\r\n  $row = $statement->fetch(PDO::FETCH_ASSOC);\r\n  $this->_data[$this->_get_id_column_name()] = $row[\"lastID\"];\r\n\r\n} else {\r\n  //...\r\n```\r\n"}}
{"actor":{"display_login":"treffynnon"}}