Good morning!
It shows the following:
Array
(
[User] => Array
(
[id] => 1
[jobTitle] => Software Engineer
[firstName] => Chris
[lastName] => Peele
[username] => cpeele
[password] => 16ea59450466058da8fed95efa0d752d8470efa0
[email] => [email protected]
[created] => 0000-00-00 00:00:00
[modified] => 0000-00-00 00:00:00
)
[Event] => Array
(
[0] => Array
(
[id] => 1
[name] => Dr Appt
[description] => Taking my son to Dr Appt this
afternoon
[user_id] => 1
[created] => 2009-03-13 13:04:48
[modified] => 0000-00-00 00:00:00
)
)
[Project] => Array
(
[0] => Array
(
[id] => 1
[name] => Matrix IBS - BarbaraJeans.com
[description] => Still waiting for customer to
approve the estimate.
[user_id] => 1
[created] => 2009-03-18 10:44:12
[modified] => 0000-00-00 00:00:00
)
)
)
On Mar 19, 12:23 pm, brian <[email protected]> wrote:
> What does this show you in the view?
>
> debug($projects);
>
> On Thu, Mar 19, 2009 at 8:59 AM, cpeele <[email protected]> wrote:
>
> > Hello, thanks for replying.
>
> > Sorry about that.
>
> > What I want is to grab all the projects that pertain to a certain
> > user...by username.
>
> > Here is what the DB tables look like:
>
> > users
> > --------------
> > id
> > firstName
> > lastName
> > username
> > password
>
> > projects
> > -----------------
> > id
> > name
> > description
> > user_id
>
> > Here is how the models look:
>
> > User
> > ------------------
> > class User extends AppModel
> > {
> > var $name = 'User';
> > var $hasMany = array('Event', 'Project');
> > }
>
> > Project
> > --------------------
>
> > class Project extends AppModel
> > {
> > var $name = 'Project';
> > var $belongsTo = 'User';
> > }
>
> > Thanks again!
>
> > On Mar 18, 9:38 pm, nhathoang nhathoang <[email protected]>
> > wrote:
> >> Dear cpeele,
> >> I see your question is not clearly , what do you want when you use this
> >> query $projects = $this->Project->User->findByUsername($username);, and
> >> please post your database on forum
>
> >> 2009/3/19 cpeele <[email protected]>
>
> >> > Hey guys, I am getting anUndefinedindexerror. I am rather new to
> >> > cakePHP so it is probably something easy I am missing.
> >> > I will post the code with descriptions.
>
> >> > I have an element called "project_updates":
> >> > <table>
> >> > <?php foreach($projects as $project): ?>
> >> > <?php $dateTime = date_create($project['Project']['created']); ?>
> >> > <tr>
> >> > <td>
> >> > <!-- ************ This link passes the "username" into
> >> > the ProjectController's view method taking the username as an argument
> >> > *******************-->
> >> > <?php echo
> >> > $html->link($project['Project']['name'],
> >> > "/projects/
> >> > view/".$project['User']['username']); ?><br />
>
> >> > <span style="font-size:12px"><?php echo
> >> > $project['User']
> >> > ['username'] . " - " . date_format($dateTime, 'd/M/y'); ?></span>
> >> > </td>
> >> > </tr>
> >> > <tr>
> >> > <td style="padding-top: 10px;">
> >> > <?php echo $project['Project']['description']; ?>
> >> > </td>
> >> > </tr>
> >> > <tr>
> >> > <td><br /></td>
> >> > </tr>
> >> > <?php endforeach ?>
> >> > </table>
>
> >> > here is the ProjectsController action code:
>
> >> > function view($username)
> >> > {
> >> > $projects =
> >> > $this->Project->User->findByUsername($username);
> >> > $this->set('projects', $projects);
> >> > }
>
> >> > Project has a foreign key reference to User. I want to grab all the
> >> > projects by a particular username that is being passed in by the above
> >> > element.
>
> >> > Here is the view.ctp code
>
> >> > <?php foreach($projects as $project): ?>
> >> > <?php echo $project['Project']['name']; ?>
> >> > <?php endforeach ?>
>
> >> > When it tries to echo the project name it throws theundefinedindex
> >> >error.
>
> >> > Any help would be greatly appreciated!
>
> >> > Thanks,
>
> >> > Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---