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
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $table | string | Target 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();