Get database row after insert in one query

At the moment I have a script where I add data to the database.

Once the data is entered I would like to get the get the row straight away.

For example if I have a query like this where I have two seperate:

    $sql = "INSERT INTO  table SET columnA '".$this->db->escape($columnA)."'";
    $query = $this->db->query($sql);
    $sql = "SELECT * FROM table";
    $query = $this->db->query($sql);
    return $query->db->row;

I want to be able to make get that database row instantly after inserting it. Will I have to make a whole new query or is there a quicker way? I am using OpenCarts API if that helps.

Thanks Peter


INSERT INTO table (a,b,c) VALUES ('a','b','c');
SELECT * FROM table WHERE your_table_primary_key = LAST_INSERT_ID();


$sql  = "INSERT INTO  table SET columnA '".$this->db->escape($columnA)."';";
$sql .= "SELECT * FROM table WHERE your_table_primary_key = LAST_INSERT_ID();"
$query = $this->db->query($sql);
return $query->db->row;

Need Your Help

Rails/Spree -bash: spree: command not found

ruby-on-rails spree

I have worked with rails before and i thought that i would try out spree to learn more about engines. Following the getting started tutorial on sprees documentation it seemed very strait forward. I

Data is not saved in DB when using Transaction annotation in JUnit test

java spring jpa junit transactions

Colleagues, I can not solve a problem with a transactions in Spring more than week.