メインコンテンツまでスキップ
Version: Fegg 5.x

Pdo::getAffectedRow

最後のクエリで追加・更新・削除した行数を取得します

説明​

public int Pdo::getAffectedRow()

最後のクエリで追加、更新、削除した行数を返します。SELECTの後の値はドライバーによって異なります(SQLiteでは0)。SELECTの行数は、allの結果を数えてください。

例​

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

$db->setValues(array('visible' => 0))->setWhere('category = ?', 3)->update('cms_news')->execute();
$updated = $db->getAffectedRow();
// -> 4