Table of Contents
A query with outlet is just a regular SQL statement except for the ability to refer to columns by their class member names. Simply wrap the identifier in curly braces and outlet will automatically replace it with the corresponding table or column name. You can even add aliases:
$bugs = $outlet->select("Bug", "INNER JOIN {Project p} ON {Bug.ProjectID} = {p.ProjectID}");
// this code will be transformed to
// SELECT bugs.*
// FROM bugs
// INNER JOIN projects p
// ON bugs.project_id = p.project_idAlthough referring to the columns by their class member name is recommended, you're always free to simple use straight sql.
<?php
$outlet = Outlet::getInstance();
// retrieve an array of Bug objects by using a prepared statement
$bugs = $outlet->select("Bug", "WHERE {Bug.StatusID} = ?", array(1));<?php $outlet = Outlet::getInstance(); // insert a bug $bug = new Bug; $bug->Title = 'This is a test bug'; $bug->ProjectID = 1; $outlet->save( $bug ); // executes an insert statement // now that the bug is saved and we're dealing with a proxy, // any subsequent calls to $outlet->save() will execute an update statement $bug->Title = 'New Title'; $outlet->save( $bug ); // executes an update statement