Select as Alias

Alias allows you to rename any table column to something else within the output.

Syntax

It is easy to customize the output data name by using aliases.


[column]~~alias

Notice that we need to wrap the column name within square brackets “[…]”.

Sample Usage


try{
	// Selecting id, first & last name, and email from the
	// users table.
        //
	// "id" will be returned as the alias "account_number".
	$s = $squibble->select('users', [
		'[id]~~account_number',
		'first_name',
		'last_name',
		'email_address'
	]);
	// collect() return an array of the result sets. This is the
	// same as PDO $query->fetchAll(PDO::FETCH_ASSOC)
	$users = $s->collect();
}catch(PDOException $e){
	echo "Error, {$e->getCode()}, {$e->getMessage()}";
}catch(Exception $e){
	echo "Error, {$e->getCode()}, {$e->getMessage()}";
}

Facebook
Twitter
LinkedIn