Re: Question about relationships, extending the blog tutorial

2010-02-25 Thread Andy Dirnberger
Glad to hear you were able to get that resolved.

Check out the documentation for the Auth component
http://book.cakephp.org/view/172/Authentication, in particular the
user method http://book.cakephp.org/view/387/user.

On Feb 24, 3:04 pm, deek  wrote:
> Andy,
>
> It looks like the debug issue was the problem and everything is now
> working properly.
>
> My final question is this.  Once a user is logged on (through the
> built-in Auth of CakePHP), what built-in functions should I use to
> determine that user's id number? For that matter what is a good way to
> test of a user is logged on or not? I ask because I would like some
> options/posts to be shown only to logged in (Admin) users.
>
> Currently this is my form for creating an new post:
> Add Post
>  echo $form->create('Post');
> echo $form->input('title');
> echo $form->input('category');
> echo $form->input('body', array('rows' => '10', 'columns' => '40'));
> echo $form->radio('frontpage', array('1'=>'Yes','0'=>'No'));
> echo $form->end('Save Post');
> ?>
>
> I want to thank everyone who has helped out with my questions.
>
> On Feb 24, 7:21 am, Andy Dirnberger  wrote:
>
>
>
> > If you have debug set to 0 in core.php and added displayname to the
> > user table after Cake first saw the it, you need to update the cache
> > of the table's layout. (Either set debug to 1, reload the page, and
> > set it back to 0 or delete the file in tmp.)
>
> > On Feb 24, 2:36 am, deek  wrote:
>
> > > Also when I try and add a user with this form
> > > Add User
> > >  > >     echo $form->create('User', array('action' => 'register'));
> > >     echo $form->input('username');
> > >     echo $form->input('displayname');
> > >     echo $form->input('password');
> > >     echo $form->end('Add User');
> > > ?>
>
> > > the displayname never makes it to the MySQL database. I have no idea
> > > why not
>
> > > On Feb 23, 11:27 pm, deek  wrote:
>
> > > > Well everything seems to be working now with "var $belongsTo =
> > > > array('User');" but I have tried putting " > > > ['displayname']; ?>" in my index.ctp and the it does not output any of
> > > > the information.  If I put  or  > > > echo $post['User']['username']; ?> those values will output just fine
> > > > but not displayname, what might cause this?
>
> > > > On Feb 23, 8:36 pm, Andy Dirnberger  wrote:
>
> > > > > Did you try just using "var $belongsTo = array('User');"? The values
> > > > > you are supplying for className and foreignKey should be the defaults.
>
> > > > > If you remove the $belongsTo piece, do your posts show up again? If
> > > > > not, what else did you change? What code do you currently have in your
> > > > > controller? No special code is needed in your controller to handle
> > > > > relationships, and you'd only need to add code to your User model
> > > > > (e.g., var $hasMany = array('Post');) if you wanted posts to be
> > > > > retrieved every time you query your user table, which you probably
> > > > > don't.
>
> > > > > Once you have it working, 'User'] will be added as an index alongside
> > > > > 'Post' (e.g., $post['User']['displayname']).
>
> > > > > On Feb 23, 5:16 pm, deek  wrote:
>
> > > > > > So I updated my post model to what you see below and now when I go 
> > > > > > to
> > > > > > my index (index.ctp) view that I have listed on my first post 
> > > > > > nothing
> > > > > > shows up. Do I need to add anything in the controllers or the user
> > > > > > model?  Once get it to show properly how would I call the the User
> > > > > > displayname in my foreach loop in the index.ctp?
>
> > > > > > class Post extends AppModel {
> > > > > >     var $name = 'Post';
> > > > > >     var $belongsTo = array (
> > > > > >         'User' => array(
> > > > > >             'className' => 'User',
> > > > > >             'foreignKey' => 'user_id'
> > > > > >         )
> > > > > >     );
> > > > > >     var $validate = array (
> > > > > >         'title' => array(
> > > > > >             'rule' => 'notEmpty'
> > > > > >         ),
> > > > > >         'category' => array(
> > > > > >             'rule' => 'notEmpty'
> > > > > >         ),
> > > > > >         'body' => array(
> > > > > >             'rule' => 'notEmpty'
> > > > > >         ),
> > > > > >         'frontpage' => array(
> > > > > >             'rule' => 'numeric'
> > > > > >         )
> > > > > >     );}
>
> > > > > > On Feb 23, 12:01 am, WebbedIT  wrote:
>
> > > > > > > ^^ What @Andy says is right.
>
> > > > > > > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > > > > > > relationships ... whichever model your foreign_key is in, it 
> > > > > > > belongs
> > > > > > > to the other model.
>
> > > > > > > Welcome to CakePHP, it should make learning complex PHP a lot 
> > > > > > > easier
> > > > > > > for you.  I sometimes wish I hadn't taught myself a lot of bad 
> > > > > > > habits
> > > > > > > by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questi

Re: Question about relationships, extending the blog tutorial

2010-02-24 Thread deek
Andy,

It looks like the debug issue was the problem and everything is now
working properly.

My final question is this.  Once a user is logged on (through the
built-in Auth of CakePHP), what built-in functions should I use to
determine that user's id number? For that matter what is a good way to
test of a user is logged on or not? I ask because I would like some
options/posts to be shown only to logged in (Admin) users.

Currently this is my form for creating an new post:
Add Post
create('Post');
echo $form->input('title');
echo $form->input('category');
echo $form->input('body', array('rows' => '10', 'columns' => '40'));
echo $form->radio('frontpage', array('1'=>'Yes','0'=>'No'));
echo $form->end('Save Post');
?>

I want to thank everyone who has helped out with my questions.

On Feb 24, 7:21 am, Andy Dirnberger  wrote:
> If you have debug set to 0 in core.php and added displayname to the
> user table after Cake first saw the it, you need to update the cache
> of the table's layout. (Either set debug to 1, reload the page, and
> set it back to 0 or delete the file in tmp.)
>
> On Feb 24, 2:36 am, deek  wrote:
>
>
>
> > Also when I try and add a user with this form
> > Add User
> >  >     echo $form->create('User', array('action' => 'register'));
> >     echo $form->input('username');
> >     echo $form->input('displayname');
> >     echo $form->input('password');
> >     echo $form->end('Add User');
> > ?>
>
> > the displayname never makes it to the MySQL database. I have no idea
> > why not
>
> > On Feb 23, 11:27 pm, deek  wrote:
>
> > > Well everything seems to be working now with "var $belongsTo =
> > > array('User');" but I have tried putting " > > ['displayname']; ?>" in my index.ctp and the it does not output any of
> > > the information.  If I put  or  > > echo $post['User']['username']; ?> those values will output just fine
> > > but not displayname, what might cause this?
>
> > > On Feb 23, 8:36 pm, Andy Dirnberger  wrote:
>
> > > > Did you try just using "var $belongsTo = array('User');"? The values
> > > > you are supplying for className and foreignKey should be the defaults.
>
> > > > If you remove the $belongsTo piece, do your posts show up again? If
> > > > not, what else did you change? What code do you currently have in your
> > > > controller? No special code is needed in your controller to handle
> > > > relationships, and you'd only need to add code to your User model
> > > > (e.g., var $hasMany = array('Post');) if you wanted posts to be
> > > > retrieved every time you query your user table, which you probably
> > > > don't.
>
> > > > Once you have it working, 'User'] will be added as an index alongside
> > > > 'Post' (e.g., $post['User']['displayname']).
>
> > > > On Feb 23, 5:16 pm, deek  wrote:
>
> > > > > So I updated my post model to what you see below and now when I go to
> > > > > my index (index.ctp) view that I have listed on my first post nothing
> > > > > shows up. Do I need to add anything in the controllers or the user
> > > > > model?  Once get it to show properly how would I call the the User
> > > > > displayname in my foreach loop in the index.ctp?
>
> > > > > class Post extends AppModel {
> > > > >     var $name = 'Post';
> > > > >     var $belongsTo = array (
> > > > >         'User' => array(
> > > > >             'className' => 'User',
> > > > >             'foreignKey' => 'user_id'
> > > > >         )
> > > > >     );
> > > > >     var $validate = array (
> > > > >         'title' => array(
> > > > >             'rule' => 'notEmpty'
> > > > >         ),
> > > > >         'category' => array(
> > > > >             'rule' => 'notEmpty'
> > > > >         ),
> > > > >         'body' => array(
> > > > >             'rule' => 'notEmpty'
> > > > >         ),
> > > > >         'frontpage' => array(
> > > > >             'rule' => 'numeric'
> > > > >         )
> > > > >     );}
>
> > > > > On Feb 23, 12:01 am, WebbedIT  wrote:
>
> > > > > > ^^ What @Andy says is right.
>
> > > > > > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > > > > > relationships ... whichever model your foreign_key is in, it belongs
> > > > > > to the other model.
>
> > > > > > Welcome to CakePHP, it should make learning complex PHP a lot easier
> > > > > > for you.  I sometimes wish I hadn't taught myself a lot of bad 
> > > > > > habits
> > > > > > by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-24 Thread Andy Dirnberger
If you have debug set to 0 in core.php and added displayname to the
user table after Cake first saw the it, you need to update the cache
of the table's layout. (Either set debug to 1, reload the page, and
set it back to 0 or delete the file in tmp.)

On Feb 24, 2:36 am, deek  wrote:
> Also when I try and add a user with this form
> Add User
>      echo $form->create('User', array('action' => 'register'));
>     echo $form->input('username');
>     echo $form->input('displayname');
>     echo $form->input('password');
>     echo $form->end('Add User');
> ?>
>
> the displayname never makes it to the MySQL database. I have no idea
> why not
>
> On Feb 23, 11:27 pm, deek  wrote:
>
>
>
> > Well everything seems to be working now with "var $belongsTo =
> > array('User');" but I have tried putting " > ['displayname']; ?>" in my index.ctp and the it does not output any of
> > the information.  If I put  or  > echo $post['User']['username']; ?> those values will output just fine
> > but not displayname, what might cause this?
>
> > On Feb 23, 8:36 pm, Andy Dirnberger  wrote:
>
> > > Did you try just using "var $belongsTo = array('User');"? The values
> > > you are supplying for className and foreignKey should be the defaults.
>
> > > If you remove the $belongsTo piece, do your posts show up again? If
> > > not, what else did you change? What code do you currently have in your
> > > controller? No special code is needed in your controller to handle
> > > relationships, and you'd only need to add code to your User model
> > > (e.g., var $hasMany = array('Post');) if you wanted posts to be
> > > retrieved every time you query your user table, which you probably
> > > don't.
>
> > > Once you have it working, 'User'] will be added as an index alongside
> > > 'Post' (e.g., $post['User']['displayname']).
>
> > > On Feb 23, 5:16 pm, deek  wrote:
>
> > > > So I updated my post model to what you see below and now when I go to
> > > > my index (index.ctp) view that I have listed on my first post nothing
> > > > shows up. Do I need to add anything in the controllers or the user
> > > > model?  Once get it to show properly how would I call the the User
> > > > displayname in my foreach loop in the index.ctp?
>
> > > > class Post extends AppModel {
> > > >     var $name = 'Post';
> > > >     var $belongsTo = array (
> > > >         'User' => array(
> > > >             'className' => 'User',
> > > >             'foreignKey' => 'user_id'
> > > >         )
> > > >     );
> > > >     var $validate = array (
> > > >         'title' => array(
> > > >             'rule' => 'notEmpty'
> > > >         ),
> > > >         'category' => array(
> > > >             'rule' => 'notEmpty'
> > > >         ),
> > > >         'body' => array(
> > > >             'rule' => 'notEmpty'
> > > >         ),
> > > >         'frontpage' => array(
> > > >             'rule' => 'numeric'
> > > >         )
> > > >     );}
>
> > > > On Feb 23, 12:01 am, WebbedIT  wrote:
>
> > > > > ^^ What @Andy says is right.
>
> > > > > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > > > > relationships ... whichever model your foreign_key is in, it belongs
> > > > > to the other model.
>
> > > > > Welcome to CakePHP, it should make learning complex PHP a lot easier
> > > > > for you.  I sometimes wish I hadn't taught myself a lot of bad habits
> > > > > by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-24 Thread WebbedIT
Can you show us the structure of your table? It seems Cake is not able
to find that field.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread deek
Also when I try and add a user with this form
Add User
create('User', array('action' => 'register'));
echo $form->input('username');
echo $form->input('displayname');
echo $form->input('password');
echo $form->end('Add User');
?>

the displayname never makes it to the MySQL database. I have no idea
why not

On Feb 23, 11:27 pm, deek  wrote:
> Well everything seems to be working now with "var $belongsTo =
> array('User');" but I have tried putting " ['displayname']; ?>" in my index.ctp and the it does not output any of
> the information.  If I put  or  echo $post['User']['username']; ?> those values will output just fine
> but not displayname, what might cause this?
>
> On Feb 23, 8:36 pm, Andy Dirnberger  wrote:
>
>
>
> > Did you try just using "var $belongsTo = array('User');"? The values
> > you are supplying for className and foreignKey should be the defaults.
>
> > If you remove the $belongsTo piece, do your posts show up again? If
> > not, what else did you change? What code do you currently have in your
> > controller? No special code is needed in your controller to handle
> > relationships, and you'd only need to add code to your User model
> > (e.g., var $hasMany = array('Post');) if you wanted posts to be
> > retrieved every time you query your user table, which you probably
> > don't.
>
> > Once you have it working, 'User'] will be added as an index alongside
> > 'Post' (e.g., $post['User']['displayname']).
>
> > On Feb 23, 5:16 pm, deek  wrote:
>
> > > So I updated my post model to what you see below and now when I go to
> > > my index (index.ctp) view that I have listed on my first post nothing
> > > shows up. Do I need to add anything in the controllers or the user
> > > model?  Once get it to show properly how would I call the the User
> > > displayname in my foreach loop in the index.ctp?
>
> > > class Post extends AppModel {
> > >     var $name = 'Post';
> > >     var $belongsTo = array (
> > >         'User' => array(
> > >             'className' => 'User',
> > >             'foreignKey' => 'user_id'
> > >         )
> > >     );
> > >     var $validate = array (
> > >         'title' => array(
> > >             'rule' => 'notEmpty'
> > >         ),
> > >         'category' => array(
> > >             'rule' => 'notEmpty'
> > >         ),
> > >         'body' => array(
> > >             'rule' => 'notEmpty'
> > >         ),
> > >         'frontpage' => array(
> > >             'rule' => 'numeric'
> > >         )
> > >     );}
>
> > > On Feb 23, 12:01 am, WebbedIT  wrote:
>
> > > > ^^ What @Andy says is right.
>
> > > > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > > > relationships ... whichever model your foreign_key is in, it belongs
> > > > to the other model.
>
> > > > Welcome to CakePHP, it should make learning complex PHP a lot easier
> > > > for you.  I sometimes wish I hadn't taught myself a lot of bad habits
> > > > by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread deek
Well everything seems to be working now with "var $belongsTo =
array('User');" but I have tried putting "" in my index.ctp and the it does not output any of
the information.  If I put  or  those values will output just fine
but not displayname, what might cause this?

On Feb 23, 8:36 pm, Andy Dirnberger  wrote:
> Did you try just using "var $belongsTo = array('User');"? The values
> you are supplying for className and foreignKey should be the defaults.
>
> If you remove the $belongsTo piece, do your posts show up again? If
> not, what else did you change? What code do you currently have in your
> controller? No special code is needed in your controller to handle
> relationships, and you'd only need to add code to your User model
> (e.g., var $hasMany = array('Post');) if you wanted posts to be
> retrieved every time you query your user table, which you probably
> don't.
>
> Once you have it working, 'User'] will be added as an index alongside
> 'Post' (e.g., $post['User']['displayname']).
>
> On Feb 23, 5:16 pm, deek  wrote:
>
>
>
> > So I updated my post model to what you see below and now when I go to
> > my index (index.ctp) view that I have listed on my first post nothing
> > shows up. Do I need to add anything in the controllers or the user
> > model?  Once get it to show properly how would I call the the User
> > displayname in my foreach loop in the index.ctp?
>
> > class Post extends AppModel {
> >     var $name = 'Post';
> >     var $belongsTo = array (
> >         'User' => array(
> >             'className' => 'User',
> >             'foreignKey' => 'user_id'
> >         )
> >     );
> >     var $validate = array (
> >         'title' => array(
> >             'rule' => 'notEmpty'
> >         ),
> >         'category' => array(
> >             'rule' => 'notEmpty'
> >         ),
> >         'body' => array(
> >             'rule' => 'notEmpty'
> >         ),
> >         'frontpage' => array(
> >             'rule' => 'numeric'
> >         )
> >     );}
>
> > On Feb 23, 12:01 am, WebbedIT  wrote:
>
> > > ^^ What @Andy says is right.
>
> > > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > > relationships ... whichever model your foreign_key is in, it belongs
> > > to the other model.
>
> > > Welcome to CakePHP, it should make learning complex PHP a lot easier
> > > for you.  I sometimes wish I hadn't taught myself a lot of bad habits
> > > by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread Andy Dirnberger
Did you try just using "var $belongsTo = array('User');"? The values
you are supplying for className and foreignKey should be the defaults.

If you remove the $belongsTo piece, do your posts show up again? If
not, what else did you change? What code do you currently have in your
controller? No special code is needed in your controller to handle
relationships, and you'd only need to add code to your User model
(e.g., var $hasMany = array('Post');) if you wanted posts to be
retrieved every time you query your user table, which you probably
don't.

Once you have it working, 'User'] will be added as an index alongside
'Post' (e.g., $post['User']['displayname']).

On Feb 23, 5:16 pm, deek  wrote:
> So I updated my post model to what you see below and now when I go to
> my index (index.ctp) view that I have listed on my first post nothing
> shows up. Do I need to add anything in the controllers or the user
> model?  Once get it to show properly how would I call the the User
> displayname in my foreach loop in the index.ctp?
>
> class Post extends AppModel {
>     var $name = 'Post';
>     var $belongsTo = array (
>         'User' => array(
>             'className' => 'User',
>             'foreignKey' => 'user_id'
>         )
>     );
>     var $validate = array (
>         'title' => array(
>             'rule' => 'notEmpty'
>         ),
>         'category' => array(
>             'rule' => 'notEmpty'
>         ),
>         'body' => array(
>             'rule' => 'notEmpty'
>         ),
>         'frontpage' => array(
>             'rule' => 'numeric'
>         )
>     );}
>
> On Feb 23, 12:01 am, WebbedIT  wrote:
>
>
>
> > ^^ What @Andy says is right.
>
> > Simple rule of thumb for hasMany/hasOne <-> belongsTo
> > relationships ... whichever model your foreign_key is in, it belongs
> > to the other model.
>
> > Welcome to CakePHP, it should make learning complex PHP a lot easier
> > for you.  I sometimes wish I hadn't taught myself a lot of bad habits
> > by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread deek
So I updated my post model to what you see below and now when I go to
my index (index.ctp) view that I have listed on my first post nothing
shows up. Do I need to add anything in the controllers or the user
model?  Once get it to show properly how would I call the the User
displayname in my foreach loop in the index.ctp?

class Post extends AppModel {
var $name = 'Post';
var $belongsTo = array (
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id'
)
);
var $validate = array (
'title' => array(
'rule' => 'notEmpty'
),
'category' => array(
'rule' => 'notEmpty'
),
'body' => array(
'rule' => 'notEmpty'
),
'frontpage' => array(
'rule' => 'numeric'
)
);
}
On Feb 23, 12:01 am, WebbedIT  wrote:
> ^^ What @Andy says is right.
>
> Simple rule of thumb for hasMany/hasOne <-> belongsTo
> relationships ... whichever model your foreign_key is in, it belongs
> to the other model.
>
> Welcome to CakePHP, it should make learning complex PHP a lot easier
> for you.  I sometimes wish I hadn't taught myself a lot of bad habits
> by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-23 Thread WebbedIT
^^ What @Andy says is right.

Simple rule of thumb for hasMany/hasOne <-> belongsTo
relationships ... whichever model your foreign_key is in, it belongs
to the other model.

Welcome to CakePHP, it should make learning complex PHP a lot easier
for you.  I sometimes wish I hadn't taught myself a lot of bad habits
by learning raw PHP first :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Question about relationships, extending the blog tutorial

2010-02-22 Thread Andy Dirnberger
Try $belongsTo instead of $hasOne.

$belongsTo = array('User');

On Feb 22, 7:03 pm, deek  wrote:
> First of all let me say I'm very new to CakePHP and complex PHP in
> general.  I based the blog I am working on off the tutorial on the
> CakePHP website. I skipped creating ACL or a more complex management
> of permissions because as of now the only people who will be posting
> content will be Authorized users so using the Auth component in both
> of my controllers with an appropriate beforeFilter() function has done
> exactly what I needed.  What I am trying to do is in my display of
> posted articles have $post['Post']['user_id']; look up the in the
> users post table the display name, I haven't found a simple answer for
> this so that is why I am posting.
>
> I've looked through the cakePHP book online and thought I might need
> to do something to link models together but I didn't have any success
> with that.  I tried having the Post model include var $hasOne = User
> but that ended up breaking everything.  Any suggestions would be
> greatly appreciated.
>
> Below are my table structures, models, and view I am working with
>
> -- Table structure for table `posts`
>
> CREATE TABLE IF NOT EXISTS `posts` (
>   `id` int(10) unsigned NOT NULL auto_increment,
>   `user_id` int(11) NOT NULL,
>   `title` varchar(50) default NULL,
>   `category` varchar(50) default NULL,
>   `body` text,
>   `frontpage` tinyint(1) NOT NULL,
>   `created` datetime default NULL,
>   `modified` datetime default NULL,
>   PRIMARY KEY  (`id`)
> )
> -- Table structure for table `users`
>
> CREATE TABLE IF NOT EXISTS `users` (
>   `id` int(11) NOT NULL auto_increment,
>   `username` char(50) default NULL,
>   `password` char(40) default NULL,
>   `displayname` varchar(50) NOT NULL,
>   PRIMARY KEY  (`id`),
>   UNIQUE KEY `username` (`username`)
>
> Post Model:
> class Post extends AppModel {
>     var $name = 'Post';
>     var $validate = array (
>         'title' => array(
>             'rule' => 'notEmpty'
>         ),
>         'category' => array(
>             'rule' => 'notEmpty'
>         ),
>         'body' => array(
>             'rule' => 'notEmpty'
>         ),
>         'frontpage' => array(
>             'rule' => 'numeric'
>         )
>     );}
>
> User model:
> class User extends AppModel {
>     var $name = 'User';
>     var $validate = array(
>         'username' => array(
>             'rule' => 'notEmpty',
>             'message' => 'Please enter your Username'
>         ),
>         'displayname' => array(
>             'rule' => 'notEmpty'
>             'message' => 'Please enter the name you wish displayed
> with your posts'
>         ),
>         'password' => array(
>             'rule' => 'notEmpty',
>             'message' => 'Pelase enter your Password'
>         )
>     );}
>
> index.ctp:  This view is on my main page and loops through all the
> posts that are tagged to be on the front page
>
>      ['frontpage']==true){ ?>
>         link($post['Post']['title'],
> array('controller' => 'posts', 'action' => 'view', $post['Post']
> ['id'])); ?>
>         
>         
>         
>         
>     

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en