Skip to content

Record::getLastSqlCmd

James Cobban edited this page Feb 5, 2022 · 3 revisions

$record->getLastSqlCmd()

Up: class Record

This returns a string containing the last SQL INSERT or UPDATE command issued by this class instance. That string is initialized by $record->save($xml). If the last save request did not require the database to be altered then this returns an empty string.

$country       = new Record(array('code' => 'CA'), 'Countries');
$country->set('name', 'British North America');
$country->save(false);
print "<p>sql='" . $country->getLastSqlCmd() . "'</p>\n";
$country->save(false);
print "<p>sql='" . $country->getLastSqlCmd() . "'</p>\n";

This displays:

sql='UPDATE Countries SET `name`='British North America' WHERE code='CA''
sql=''

Next: $record->__toString()

Clone this wiki locally