is there an alternative for mysql_insert_id() php function for PostgreSQL? Most of the frameworks are solving the problem partially by finding the current value of the sequence used in the ID. However, there are times that the primary key is not a serial column....
...
I have the following query:
INSERT INTO table (a) VALUES (0)
ON DUPLICATE KEY UPDATE a=1
I want the ID of either the insert or the update. Usually I run a second query in order to get this as I believe insert_id() only returns the 'inserted' ID and not the updated ID.
Is there a way to INSERT/UPDATE and retrieve the ID of the row wi...
Hi All,
I am inserting a row with a char column for a hash based on (among other things) the row's auto id.
I know I can insert it, fetch the insert_id, calculate the hash, and update it.
Does anyone know of a way to do this in a single query? You would need the rows insert_id at the time of insert. Is that completely impossible, ...
Hi guys!
Im wondering if the way i use to retrieve the id of the last row inserted in a postgresql table is efficent..
It works, obviously, but referencing on the serial sequence currval value could be problematic when i have many users adding rows in the same table at the same time.
My actual way is:
$pgConnection = pg_connect('host...
Hello All,
I'm currently working on creating a private messaging system, (PHP/MySQL) in which users can send message to multiple recipients at one time, and those users can then decide to reply.
Here's what I'm currently working with:
tbl_pm tbl:
id
date_sent
title
content
status ENUM ('unread', 'read') DEFAULT 'unread'
tblpm_info t...
If the next is right:
There are SQL string with multiple inserts (using a stored procedure):
"EXEC SPInsertData ... EXEC SPInsertData ... EXEC SPInsertData ..."
The id in identity column, which is auto incremented, of every new record is smaller than the id of the next one.
E.g. after executing the given SQL string the id of the first...
I'm trying to some something like that:
INSERT INTO dir_pictures SET filename=CONCAT(picture_id,'-test');
picture_id is my primary key, auto-increment. Basically I'm trying to put the id of this insert statement, in the statement itself.
I'm sure it can be done with some extra PHP code or using more than one statements, but I was won...
I want to INSERT a record in a database (which is Microsoft SQL Server in my case) using JDBC in Java. At the same time, I want to obtain the insert ID. How can I achieve this using JDBC API?
...
I'm experiencing my first mysql INSERT tests and I'm using these tables:
table employees
-> employee_id
-> employee_name
-> employee_surname
-> employee_url
table areas
-> area_id
-> area_city
-> area_address
-> area_country
table agencies
-> agency_id
-> agency_name
-> agency_url
table node_employees
-> node_id
-> employee_id
-> are...
How would I get the last inserted ID using a multirow insert?
Here is my code:
$sql='INSERT INTO t (col1, col2, col3) VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9)'; // example
$stmt = $contactsTable->getAdapter()->prepare($sql);
$stmt->execute();
$rowsAdded=$stmt->rowCount(); // mysql_affected_rows
$lastId=$stmt->lastInsertId();
echo '<br>La...
I am using adodb for PHP library.
For fetching the id at which the record is inserted I use this function "$db->Insert_ID()"
I want to know if there are multiple and simultaneous inserts into the database table, will this method return me the correct inserted id for each record inserted ?
The reason I am asking this is because I use t...
Hello all,
Both the MySQLi and MySQLi_STMT classes have an $insert_id property.
If I am connected to my database using a MySQLi object (say $db), and then I perform an INSERT with a MySQLi_STMT object (say $stmt), to get the id of the last INSERT, should I use:
$last_id = $db->insert_id;
or
$last_id = $stmt->insert_id;
Or would ...
Is there an internal ID variable or timestamp I can use in a NSSortDescriptor to retrieve Core Data entities in the order they were inserted?
I would rather not have to create such properties if there is a cleaner way, though will obviously do so if there are no other alternatives.
...
Hi..guys
I am trying to insert date and time into mysql datetime field. When a user select a date and time, it will generate two POST variables. I have searched internet but still not sure how to do it.
My code.
//date value is 05/25/2010
//time value is 10:00
$date=$_POST['date'];
$time=$_POST['time'];
$datetime=$date.$time
If...