Questions tagged [lastinsertid]

135 questions
1
vote
3 answers

SELECT LAST_INSERT_ID() *updated

I'm looking to use SELECT LAST_INSERT_ID() Am using a form to have a user input values. With the first insert I need to get the last inserted id for the next insert... I have not figured out how to get the last selected id and then pass it into my…
Droid646197
  • 65
  • 2
  • 2
  • 8
1
vote
1 answer

Informix: How to get the rowid of the last insert statement

This is an extension of a question I asked before: C#: How do I get the ID number of the last row inserted using Informix I am writing some code in C# to insert records into the informix db using the .NET Informix driver. I was able to get the id of…
myermian
  • 31,823
  • 24
  • 123
  • 215
1
vote
1 answer

insert_id in Kohana 3

I'm using Kohana 3 framework with Mysql stored procedures. How can I get id of the last inserted record? Here's the code: class Model_MyModel extends Kohana_Model { public function insertNew($param1, $param2) { $result =…
skog
  • 31
  • 1
  • 4
1
vote
2 answers

php lastInsertId(). Undefined variable in a form value for array

I am having a problem passing $last: $last = $db->lastInsertId(); I need to pass lastInsertId() in array from form field lastInsertId() works because near the form I get the…
rafpre
  • 29
  • 5
1
vote
0 answers

How to get last insert row in laravel 5,my id is autoincrementing

My tid is autoincrementing, i want to get that tid. or I want to get the last inserted row. I need to use this tid in another table. Please help me class Transaction extends Model { protected $table = 'tbl_transaction'; public function…
Visal Varghese
  • 436
  • 5
  • 14
1
vote
1 answer

MySqlCommand.LastInsertedId return 0

I'm trying to execute stored procedure and to return last instered id but each time the result is 0. This is how I do it: public long InsertActivity(cActivities objAct) { long lastID = 0; try { …
Josef
  • 2,648
  • 5
  • 37
  • 73
1
vote
2 answers

Get last id of an entity in hibernate

I need a way to fetch the last id of an entity in database, let's say for example Product entity: I try this but its not working: public int lastInsertedId() { try { if (!session.isOpen()) session =…
abdou amer
  • 819
  • 2
  • 16
  • 43
1
vote
2 answers

php function last_insert_id() is not working with REPLACE INTO query

I am using REPLACE INTO query to insert in to table but after executing query by using mysql_query() function and if I use last_insert_id() it is only giving me 0 value. why this is happening so? and how can I overcome this behavior. :Pankaj
Pankaj Khairnar
  • 3,028
  • 3
  • 25
  • 34
1
vote
1 answer

Can I get INSERT/UPDATE id with single request?

I have the following code: $put_tag_rq = $DBH->prepare( " INSERT INTO `tags` SET `name` = :name ON DUPLICATE KEY UPDATE `id` = `id` " ); $put_tag_rq->execute( array( 'name' => $tag, ) ); $tag_id = $DBH->lastInsertId(); echo…
user2525317
  • 177
  • 1
  • 10
1
vote
1 answer

How to get the last insert ids from laravel 4

I am using laravel 4. I have a table called documents. I am inserting data in the Document table using Document::insert() function. My code is given below $statuses = array(); foreach($content as $i){ array_push($statuses, array( …
odbhut.shei.chhele
  • 5,834
  • 16
  • 69
  • 109
1
vote
2 answers

How to change one-to-one relationship to one-to-many relationship in MySQL?

I currently have a user's table which contains a one-to-one relationship for Youtube OAuth tokens. However, I now want to support multiple video sites and want to break this into a one-to-many relationship. I have setup the new tables: tokens -…
Matt McCormick
  • 13,041
  • 22
  • 75
  • 83
1
vote
1 answer

LastInsertId PHP

Im trying to get the last inserted record to be displayed. At the moment i'm trying to echo my binded value for last inserted id. $stmt= $dbh->prepare("INSERT INTO child (FName, LName, Age, Sex, Allergies) values (:FName, :LName, :Age,…
1
vote
1 answer

With Kohana 3, how can I get the last insert ID from the Database class?

I have been through a fair bit of the code in modules/database/classes/ but still have not found how to return the last insert Id. How do I get this?
alex
  • 479,566
  • 201
  • 878
  • 984
1
vote
2 answers

Retrieve last_insert_id when performing multiple queries

I have read the MySQL-bug list, where I found out, that last_insert_id() returns the FIRST auto_increment-value when you're performing multiple insert statements. (Link: http://bugs.mysql.com/bug.php?id=34319) My problem is, that in my code, I…
denlau
  • 916
  • 2
  • 9
  • 21
1
vote
1 answer

CakePHP 1.3 not saving to database but sql statement is correct and insertID is increased correctly

I already searched many forums for my really strange issue, but I still can't figure out whats going wrong during my save process... The issue: Cake says, my data was saved, creates an autoincrement-ID but no record is stored in the database. The…
TurbuLenz
  • 45
  • 1
  • 9
1 2 3
8 9