Dusan Djordjevic Mon Oct 03 18:07:55 -0400 2011

Subject: Begginer need simple help with PHP AC...

Hello guys,

I am pretty much new in phpAR and i need some help to get me started.
My tables are looking like this:

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `fname` varchar(100) DEFAULT NULL,
  `lname` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)

CREATE TABLE `user_emails` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)

The model class for USER is the follwoing:

class User extends ActiveRecord\Model {
     static $has_many = array(

So now I want to get a full USER object that matches firstname 'Peter' and email ''

function getUser() {
     $user = $this::first(array('conditions' => array('user_emails.email = ? AND fname = ?', 'email@email.com', 'Peter')));

BUT that code gives me :

Unknown column 'user_emails.email' in 'where clause'



Nanne Huiges Tue Oct 04 10:17:40 -0400 2011

The join on user_emails isn't done automatically, so you have to provide the join (see http://www.phpactiverecord.org/projects/main/wiki/Finders#joins ) yourself