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

Pdo::unsetInitQueryFlag

Disable reset query flag

Description​

public self Pdo::unsetInitQueryFlag()

Keeps what was set (items, conditions, joins, order, limit ...) after execute, so the next query can reuse it. Model::find() uses it to count and fetch with the same conditions. Turn it back on with setInitQueryFlag, or drop everything with reset.

Example​

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

// Count and fetch with the same conditions
$db->unsetInitQueryFlag()->setWhere('category = ?', 2);
$count = $db->count('cms_news')->execute()->one();

$db->setInitQueryFlag()->setLimit(10);
$rows = $db->select('cms_news')->execute()->all();