Friday, October 3, 2008

Re: Notice (8): Undefined index: abc [APP\views\......\index.ctp

Note also you have to have your tables defined according to the
CakePHP syntax. Each one should have an "id" key column. Then the Book
table should have an author_id field to link the author.

On Oct 3, 2:54 pm, qwanta <rgmic...@gmail.com> wrote:
> If it's a one to many relationship (author has many books, each book
> has one author):
>
> In Book Model you stick this:
> var $belongsTo = array ('Author');
>
> In Author Model:
> var $hasMany = array ('Book');
>
> http://book.cakephp.org/view/78/Associations-Linking-Models-Together
>
> I'd recommend going through these tutorials:
>
> http://www.sitepoint.com/article/application-development-cakephp/http://www.davidgoldingdesign.com/newbie-cakephp.pdf
>
> On Oct 3, 1:36 pm, "Abdus Salaam" <abdusal...@gmail.com> wrote:
>
> > thanx for ur time.
> > - ya u r rite that htmlhelper is easy way to genrate tables cell and
> > headers..
> > but i m trying to learn some code myself.. :p
> > - i m trying to made relationship b/w books and authors tables...i think its
> > relation is not make properly.
> > -how to make foreign key?..i think thats the problem.
> > thanx
>
> > On Fri, Oct 3, 2008 at 11:13 PM, qwanta <rgmic...@gmail.com> wrote:
>
> > > What you probably want to do is take a look at what you have in the
> > > $books array at the end of your controller. A quick and dirty way is
> > > to put a var_dump($books); as last statement in your controller
> > > function. The contents will then show up at the top of your view.
> > > Check if the ['Author']['name'] data is there.
> > > Does it work without recursive=1? (My guess is the problem is to do
> > > with the Author table and your model definition)
>
> > > FYI, the htmlhelper::tableCells & tableHeaders functions are nice for
> > > generating tables. :)
>
> > > I believe also that the preferred way in cakephp 1.2 to optimize
> > > database calls is to use containable behavior. ie.
> > > replace
> > > $this->Book->recursive = 1;
> > > with
> > > $this->Book->contain('Author');
>
> > >http://cakebaker.42dh.com/2008/05/18/new-core-behavior-containable/
>
> > > But try getting it to work first without optimization.
>
> > > On Oct 3, 1:14 am, "S/*\\L/*\\L/*\\M" <abdusal...@gmail.com> wrote:
> > > > hi all,
> > > > i m very new in cakePHP, pls help me some one about this error, which
> > > > is headeach for me.
> > > > => i m getting error of [Undefined index] in abc view file.i m
> > > > pasting code here if some 1 got it then pls help me.
> > > > thanx
>
> > > > =>this controller file code for index...
> > > > function index() {
> > > > $this->Book->recursive = 1;
> > > > $books = $this->Book->find('all');
> > > > $this->set('books', $books);
>
> > > > }
>
> > > > =>and this one code for index.ctp
> > > > <?php foreach($books as $book): ?>
> > > > <tr>
> > > > <td><?php echo $book['Book']['isbn']; ?></td>
> > > > <td><?php echo $book['Book']['title']; ?></td>
> > > > <td><?php echo $book['Author']['name'] ;?></td>
> > > > </tr>
> > > > <?php endforeach; ?>
> > > > ....i am waiting :)
>
> > --
> > Best Regards
> > ABDUS SALAAM
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: