メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Pdo::getReturnCode

Get return code of the last executed query

Description​

public int|null Pdo::getReturnCode()

Returns the number of affected rows of the last query that was not a SELECT or PRAGMA (null before the first one). Prefer getAffectedRow. A failed query throws Fegg\Database\QueryException, so there is no error code to check.

Example​

Controller
$db = new \Fegg\Database\Pdo();

$db->setValues(array('title' => 'Sample'))->insert('cms_news')->execute();
$code = $db->getReturnCode();
// -> 1