I've just began focusing on a task and i'm using zend framework and postgresql (normally use MySQL) however am striking an issue after i am looking to get the final placed id while using the Zend_Db place command.
While using the function
$db->lastinsertid('users', 'userid'); I recieve the next error message:
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "users_userid_seq" does not exist LINE 1: SELECT CURRVAL('users_userid_seq') ^
I have checked the database and also the sequence does exist, and both table and also the sequence is possessed through the exactly the same user that's being use to gain access to the applying.
I have even attempted
$db->lastSequenceId('users_userid_seq'); but nonetheless obtain the same error message.
I don't know if the issue is with postgresql (I believe probably) or using the framework.
Has other people were built with a similar problem for this?
I help you found the way to go, it had been just a typographical error.
FWIW, I'll provide the following suggestion as the second reason behind the mistake you saw:
You have to spell the title from the sequence exactly because it is saved, including matching situation when the sequence title is saved as anything apart from lower-situation.
Quite simply, when the sequence was produced using the spelling "
Users_userid_seq," however, you queried it as being "
users_userid_seq," this does not match and you will get the mistake.
Try listing sequences within the
This will highlight the sequences defined, using their spelling because they are saved within the database.
See if the schema on the table "customers" is incorporated in the "search_path" from the Zend_Db session.
The area "userid" is really a primary type in the table "customers" ? When not, alter the userid type.
The next code works best for me (PostgreSQL &lifier Zf)
$id = $db->lastSequenceId($this->_sequence) //Replace $this->_sequence using the sequence you're using within the database