Friday, December 08, 2006

Simpl Join()!

Its amazing how much code can be reduced by using a framework, especially a framework that accomplishes all the most basic elements without interfering with usability. With Simpl we are trying to accomplish just that. So we recognized the problem of information being in two different tables and having two queries just was not cutting it. So we are proud to announce the Join() function in DbTemplate. This is now integrated into the examples also to get you up and running with it.

Here is a sample code snipit of joining the Registration, User and Payments tables to view information all in one list with one query:
// Create the Registration class
$myRegistration = new Registration;
$display[] = array('registration_id','user_id','date_registered','guests');

// Create the User Class
$tmpUser = new Users;
$myRegistration->Join($tmpUser, 'user_id', 'INNER');
$display[] = array('first_name','last_name');

// Create the Payments Class
$tmpPayment = new Payment;
$myRegistration->Join($tmpPayment, 'conference_id', 'INNER');
$display[] = array('conference_id', 'amount', 'status', 'method');

// Get a list of all the Registrations
$myRegistration->GetList($display,'date_registered','DESC');

Questions or Concerns? Head over to our Simpl Group.

No comments: