Menu

Getting INSERT id.

Help
Francis
2002-05-16
2002-06-10
  • Francis

    Francis - 2002-05-16

    Hi,
         PHPLib is great but I want to get the primary ID/key after I have done an INSERT.

    Thanks

     
    • Richard Archer

      Richard Archer - 2002-05-17

      I use $db->nextid() to create a new id and perform the insert specifying that as the key.

      Only works if records are added only using the PHP script though. Otherwise your sequence and id's can get out of sync.

      ...R.

       
    • Francis

      Francis - 2002-06-10

      Is their anyother way to do this? as this is a BIG sticking point...

       
    • Layne Weathers

      Layne Weathers - 2002-06-10

      If you are using MySQL, add this function to your local.inc extension of DB_Sql.

      function insert_id() {
          return @mysql_insert_id($this->Link_ID);
      }

       

Log in to post a comment.