1. Basic Querying

On a very low level can call raw queries as in Figure 2.

Figure 2. Raw Query
$database->query('SELECT * FROM user');	// returns results of raw queries

Eden's PostGre object uses PDO to communcate with your database. It's recommended you bind incoming variables contributed by the end user. Still on a low level, this can be acheived as in Figure 3.

Figure 3. Raw Binding
$query 	= 'SELECT * FROM user WHERE user_name LIKE :user_name AND user_active = :user_active';
$bind 	= array(':user_name' => '%'.$userName.'%', ':user_active' => 1);

$database->query($query, $bind);	// returns results of raw queries

The above figure sets $query to a string with binded place holders :user_name and :user_active. $bind has the actual values these placeholders and should be replaced with duing execution of the query. We encourage this method because binding values prevents database injections.

Binded variables must start with a colon(:).

© 2012 Openovate Labs. All rights reserved.