This question already has an answer here:
I am manually adding a record using
PHP (sourcerer) into
Jdatabase. I wish to select the record that was
added using the insert query below. Is there a wayout without using another query with where clause to get the same record added by the insert query? Thanks in advance.
I don't want to get the last row of the table in which the record was inserted.
$query = $db->getQuery(true); $columns = array('teacher_id', 'sub_code','active'); $values = array($db->quote($teacher), $db->quote($sub_code),1); $query ->insert($db->quoteName('#__teachers_classes')) ->columns($db->quoteName($columns)) ->values(implode(',', $values)); $db->setQuery($query); $db->execute();