select()

select($condition, $alias = null, $only = true, $override = false)

This method create customized element alias for you SELECT ( find, get ) queries
@param String $condition
@param String $alias
@param Boolean $only ( DEPRECATED )
@param Boolean $override
@return PhpBURN_Core

Params


$condition
The SELECT condition, for example: “COUNT(id_users)” or “name”

$alias
The alias to be outputed to the model example: “total” or “full_name”

$only (deprecated)

$override (optional)
Optional field that clean all select() used before and starts again.

Explanation


Sometimes you need to use a function or even give another name for that field you mapped, well, now you can EASY EASY…

Let’s see how to use a function to COUNT the registers for example:

$user = new Users();

$user->select('COUNT(id_users)','total');
$user->groupBy('id_users');

$totalLines = $user->find();

print $user->fetch()->total;

Note that $totalLines is different from total, in $totalLines in this case will return 1 while $user->total will return the amount of items in the table.