title: postgresql sequence problems with lastinsertid and zend framework
body: <p>I have just started working on a project and I am using zend framework and postgresql (normally use MySQL) however I am hitting a problem when I am trying to get the last inserted id when using the Zend_Db insert command.</p>
  
  <p>When using the function <code>$db-&gt;lastinsertid('users', 'userid');</code> I get the following error message:</p>
  
  <pre><code>SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "users_userid_seq" does not exist LINE 1: SELECT CURRVAL('users_userid_seq') ^
  </code></pre>
  
  <p>I've checked the database and the sequence does exist, and both the table and the sequence is owned by the the same user that is being use to access the application.</p>
  
  <p>I've even tried <code>$db-&gt;lastSequenceId('users_userid_seq');</code>  but still get the same error message.</p>
  
  <p>I am not sure if the problem is with postgresql (I think most likely) or with the framework.  </p>
  
  <p>Has anyone else had a similar problem to this?</p>