Well assuming that's the proper method call... $project = ProjectPeer::retreiveByPk(); $firstname = $project->getUser->getFirstName(); print $firstname;
also it looks like the column name for first name is actually name_first according to the schema you posted so the method name would be getNameFirst() On 3/19/07 12:33 AM, "Sid Bachtiar" <[EMAIL PROTECTED]> wrote: > > Ok, from the schema I think $project->getUser()->getNameFirst() should > really work. > > Unless $project isn't an object in the first place since you said: > >>>>> $project->getCreatedBy()->getFirstName() >>>>> >>>>> But this gives me a cannot call method on non-object error. > > which could mean that $project isn't an object in the first place. > > A little snippet of where you put that line might be useful to > determine the problem. > > On 3/19/07, Craig Boxall <[EMAIL PROTECTED]> wrote: >> >> <table name="user" phpName="User"> >> <column name="id" type="integer" required="true" >> primaryKey="true" >> autoIncrement="true" /> >> <column name="uname" type="varchar" size="15" /> >> <column name="pword" type="varchar" size="100" /> >> <column name="user_group_id" type="integer" >> default="0" /> >> <foreign-key foreignTable="user_group"> >> <reference local="user_group_id" >> foreign="id"/> >> </foreign-key> >> <column name="name_first" type="varchar" size="100" >> /> >> <column name="name_last" type="varchar" size="100" /> >> <column name="email" type="varchar" size="100" /> >> <column name="position" type="varchar" size="100" /> >> <column name="phone_1" type="varchar" size="20" /> >> <column name="phone_2" type="varchar" size="20" /> >> <column name="created_at" type="timestamp" /> >> <column name="updated_at" type="timestamp" /> >> <column name="logged_at" type="timestamp" /> >> <column name="created_by" type="integer" /> >> <column name="updated_by" type="integer" /> >> <column name="is_active" type="tinyint" size="1" /> >> <column name="is_deleted" type="tinyint" size="1" /> >> </table> >> >> <table name="project" phpName="Project"> >> <column name="id" type="integer" required="true" >> primaryKey="true" >> autoIncrement="true" /> >> <column name="jobnum" type="varchar" size="6" /> >> <column name="client_id" type="integer" /> >> <foreign-key foreignTable="client"> >> <reference local="client_id" foreign="id"/> >> </foreign-key> >> <column name="title" type="varchar" size="100" /> >> <column name="description" type="varchar" size="255" >> /> >> <column name="created_at" type="timestamp" /> >> <column name="updated_at" type="timestamp" /> >> <column name="created_by" type="integer" /> >> <foreign-key foreignTable="user"> >> <reference local="created_by" foreign="id" /> >> </foreign-key> >> <column name="updated_by" type="integer" /> >> <foreign-key foreignTable="user"> >> <reference local="updated_by" foreign="id" /> >> </foreign-key> >> <column name="duedate" type="timestamp" /> >> <column name="is_active" type="tinyint" size="1" /> >> <column name="is_deleted" type="tinyint" size="1" /> >> </table> >> >> On 19/03/2007, at 4:18 PM, Sid Bachtiar wrote: >> >>> >>> Show us the schema.yml or schema.xml >>> >>> On 3/19/07, Craig Boxall <[EMAIL PROTECTED]> wrote: >>>> >>>> Thanks Ant, >>>> >>>> Yes getCreatedBy() returns the id of the user (which in this case is >>>> "1") so myscript echoes >>>> "Created by 1" >>>> Instead of: >>>> "Created by Craig" >>>> >>>> >>>> I tried what you suggest and I get the following error: >>>> >>>> Call to undefined method Project::getUser() >>>> >>>> when trying: >>>> >>>> $project->getUser()->getNameFirst(); >>>> >>>> Any suggestions? >>>> >>>> Cheers >>>> >>>> >>>> >>>> On 19/03/2007, at 3:52 PM, Ant Cunningham wrote: >>>> >>>>> >>>>> I believe getCreatedBy() is only giving you the ID not the object >>>>> it is >>>>> linking to. try using $project->getUser()->getFirstName(); it seems >>>>> odd >>>>> because youre not using the default naming pattern (ie. user_id as >>>>> a value >>>>> is getUserID(), user as an object is getUser()), the proxy to get >>>>> the >>>>> related record is created by the related class name, not the column >>>>> name. >>>>> >>>>> **I think** >>>>> >>>>> :-) >>>>> >>>>> >>>>> On 3/18/07 11:11 PM, "Craig Boxall" <[EMAIL PROTECTED]> >>>>> wrote: >>>>> >>>>>> >>>>>> Hi everyone, >>>>>> >>>>>> This is my first post to the symfony group so go easy on me :) Im >>>>>> also super-new at Symfony and I have what I imagine is a simple >>>>>> question. >>>>>> >>>>>> I have two modules >>>>>> >>>>>> -> Project >>>>>> -> User >>>>>> >>>>>> One of the fields in my Project table is created_by to store the ID >>>>>> of the user who created the project. I have set up a foreign key to >>>>>> link this to the User table. >>>>>> >>>>>> When creating new records it gives me a drop down of all the >>>>>> records >>>>>> in my user table (by ID number not name) so I am able to capture a >>>>>> user just fine. >>>>>> >>>>>> Now when I list the Projects, I want to be able to do something >>>>>> like: >>>>>> >>>>>> $project->getCreatedBy()->getFirstName() >>>>>> >>>>>> But this gives me a cannot call method on non-object error. >>>>>> >>>>>> Any suggestions how I make this work? >>>>>> >>>>>> Thanks to any help. >>>>>> >>>>>> regards >>>>>> Craig >>>>>> >>>>>> >>>>>>> >>>>> >>>>> >>>>> >>>>>> >>>> >>>> >>>>> >>>> >>> >>>> >> >> >>> >> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
