Using Functions

Functions, built-in or user defined, are great for altering and/or manipulating data for the output. They can also be used on the operands for more complex comparisons.


Ensure the column is wrapped in squared brackets “[column]”.

// Single function
function([column] [, arguments])

// Multiple functions
function_1(function_2(function_n([column] [, arguments])))

Sample Usage

In a previous example we selected a user from the users table whose email address is “[email protected]” by applying the following filter to the WHERE clause: [ ’email_address[=]’ => ‘ [email protected] ‘ ]. This time we want to standardize the left operand, email_address, so that it is case insensitive—a great way to do that is to apply the built-in function lower(string $string).

	// Select a user whose email address is [email protected]
	$s = $squibble->select('users', [
		'lower([email_address])[=]' => '[email protected]'        
	// collect() return an array of the result sets. This is the
	// same as PDO $query->fetchAll(PDO::FETCH_ASSOC)
	$user = $s->collect();
}catch(PDOException $e){
	echo "Error, {$e->getCode()}, {$e->getMessage()}";
}catch(Exception $e){
	echo "Error, {$e->getCode()}, {$e->getMessage()}";