SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post How do i select this

    Hi, can i ask some question, I know how to get the last inserted id if the field is auto_increment...now my problem is that how can i get the last inserted id which is not auto_incremented...? is there a function or do i need to issue an PDO select statement ?


    let says this is my table name "student" the std_id is not auto_increment but i set as primary key,the last issue for inserting statement is std_id = '8',how can i get that value 8 because i am going to insert it to other table,do i need to select first ?but how can i select the last row ?
    Code:
      std_id              std_name      std_age
        5                   mike             18
        8                   jean              26


    Thank you in advance

  2. #2
    SitePoint Evangelist captainccs's Avatar
    Join Date
    Mar 2004
    Location
    Caracas, Venezuela
    Posts
    516
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If the id is not auto incremented then the code knows the last ID it inserted because it assigned that id to the last insert query.

    You could add each insert id to a stack and know the whole history.

    Am I missing something?
    Denny Schlesinger
    web services

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi, Thank you it solved my problem


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •