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

Pdo::compile

Compile built query (not execute)

Description​

public self Pdo::compile()

Builds the query without running it or forgetting it. Read it with getQuery and getParam, or with the values filled in with getLastQuery.

Example​

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

$db->setWhere('category = ?', 2)->setOrder('created desc')->setLimit(10, 20)->select('cms_news')->compile();

echo $db->getQuery();
// -> Select * From "cms_news" Where category = ? And "cms_news".valid = 1 Order By created desc Limit 20, 10
print_r($db->getParam());
// -> Array ( [0] => 2 )