Skip to main content
Version: Fegg 5.x (next)

Pdo::select

Set select query

Description​

public self Pdo::select( string $table )

Builds a SELECT on $table from what was set with setItem (columns, default *), setJoin / setOn, setWhere, setGroup, setHaving, setOrder and setLimit. CURRENT_TABLE.valid = 1 is added (see Configuration). Run it with execute.

Arguments​

NameData typeDefaultRemarks
$tablestringTarget table name

Example​

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

// Select * From "cms_news" Where category = ? And "cms_news".valid = 1 Order By post_date DESC Limit 0, 10
$rows = $db->setWhere('category = ?', 2)
->setOrder('post_date DESC')
->setLimit(10)
->select('cms_news')
->execute()
->all();