public function getInsertId($sequence = NULL) { $this->connected || $this->connect(); $id = $this->driver->getInsertId($sequence); if ($id < 1) { throw new Exception('Cannot retrieve last generated ID.'); } return (int) $id; }