It means that you are calling a member function of something that *is
not* an object.

2007/12/1, Joyce <[EMAIL PROTECTED]>:
>
> What does it mean by "Fatal error: Call to a member function on a non-
> object"?
>
>
> On Dec 2, 2:17 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > Hi,
> >
> > Hi,
> >
> >
> >
> > > Here's my Category model:
> >
> > > <code>
> > > <?php
> > > class Category extends AppModel {
> >
> > >         var $name = 'Category';
> > >         var $displayField = 'cat_name';
> > >         var $validate = array(
> > >                 'catList' => VALID_NOT_EMPTY,
> > >                 'id' => VALID_NOT_EMPTY,
> > >                 'cat_name' => VALID_NOT_EMPTY,
> > >         );
> > >         var $hasMany = array ('Product' => array(
> > >                 'className' => 'Product',
> > >                 'conditions'=> '',
> > >                 'order'=> '',
> > >                 'foreignKey'=>'cat_id')
> > >         );
> >
> > > }
> > > ?>
> > > </code>
> >
> > The Category model is fine.
> >
> >
> >
> > > Product Model:
> > > <code>
> > > <?php
> > > class Product extends AppModel {
> >
> > >         var $name = 'Product';
> >
> > >         var $hasAndBelongsToMany = array ('Category' => array(
> > >         'className' => 'Category',
> > >         'conditions'=> '',
> > >         'order'=> '',
> > >         'foreignKey'=>'cat_id')
> > >     );
> > > }
> > > ?>
> > > </code>
> >
> > The Product model is wrong.
> >
> > It should be:
> >
> > <?php
> > class Product extends AppModel {
> >
> >         var $name = 'Product';
> >
> >         var $belongsTo = array ('Category' => array(
> >         'className' => 'Category',
> >         'foreignKey'=>'cat_id')
> >     );}
> >
> > ?>
> >
> > The association is wrong, it should be Product belongsTo Category. Fix
> > it, and try.
> >
> >
> >
> > > ASCII code? Do you mean this?
> >
> > > Categories:
> > > +------------+-------------+------+-----+---------+----------------+
> > > | Field      | Type        | Null | Key | Default | Extra          |
> > > +------------+-------------+------+-----+---------+----------------+
> > > | id               | int(5)          |      | PRI | NULL    |
> > > auto_increment |
> > > | cat_name   | varchar(50)  |      |     |         |                |
> > > | cat_parent  | int(5)          |      |     | 0
> > > |                |
> > > +------------+-------------+------+-----+---------+----------------+
> >
> > > Products:
> > > +----------+--------------+------+-----+---------+----------------+
> > > | Field    | Type         | Null | Key | Default | Extra          |
> > > +----------+--------------+------+-----+---------+----------------+
> > > | id              | int(20)      |      | PRI | NULL    |
> > > auto_increment |
> > > | cat_id        | int(5)       |      |     | 0       |
> > > |
> > > | productname  | varchar(100) |      |     |         |
> > > |
> > > +----------+--------------+------+-----+---------+----------------+
> >
> > I would prefer something like:
> >
> > Category:
> >  id
> > auto_increment
> > cat_name
> > cat_parent
> >
> > Products:
> > id
> > auto_increment
> > cat_id                   // make this category_id and you would
> > haven't to configure it.
> > productname
> >
> > > Thanks.
> >
> > You are welcome.
> >
> > And please, read the manual and take pay attention to conventions!
> >
> >
> >
> > > On Dec 1, 11:36 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > > 2007/12/1, Joyce <[EMAIL PROTECTED]>:
> >
> > > > Hi,
> >
> > > > > I would like to apologize for being a nuisance. It is ok. Your English
> > > > > is understandable, it is only probably I couldn't get the point, not
> > > > > really used to using cakePhp, somehow have a sense of being
> > > > > restricted, which may be the fact that I am not used to it.
> >
> > > > yes, I felt like that in the beginning, now I love CakePHP.
> >
> > > > > Hardcoring can get things pretty straight forward, but it takes time.
> > > > > Hence, it is kind of a trade off in between.
> >
> > > > > > If you have all associations set correctly, you can put in the
> > > > > > ProductsController:
> >
> > > > > Is there anything that I will need to set in besides this:
> > > > > $this->set('categories', $this->Product->Category->generateList(null,
> > > > > null, null,
> > > > > "{n}.Category.id", "{n}.Category.catname"));
> >
> > > > > Is it the $hasMany (for Product) and $BelongsTo (Category) under their
> > > > > model?
> >
> > > > > If it is these, then I have tried but there is an issue whenever I do
> > > > > any action to them (add, edit, etc), they will prompt for the table
> > > > > products_categories error. Do I have to set a table for it, or
> > > > > otherwise? Below is the output result:
> >
> > > > > <output result>
> >
> > > > > Query: DELETE FROM `categories_products` WHERE cat_id = '7'
> > > > > Warning: SQL Error: 1146: Table 'testdb.categories_products' doesn't
> > > > > exist in /home/testdb/cake/libs/model/datasources/dbo_source.php on
> > > > > line 440
> >
> > > > > Query: INSERT INTO `categories_products` (cat_id,category_id) VALUES
> > > > > (7,6)
> > > > > Warning: SQL Error: 1146: Table 'testdb.categories_products' doesn't
> > > > > exist in /home/testdb/cake/libs/model/datasources/dbo_source.php on
> > > > > line 440
> >
> > > > > Warning: Cannot modify header information - headers already sent by
> > > > > (output started at /home/testdb/cake/basics.php:697) in /home/testdb/
> > > > > cake/libs/controller/controller.php on line 447
> >
> > > > > </output result>
> >
> > > > Seems like you have wrong your associations. Can you post the source
> > > > code from both models and the tables definitions (just ASCII, no SQL
> > > > please)?
> >
> > > > And maybe have a look at :
> >
> > > > *http://manual.cakephp.org/chapter/models
> > > > *http://tempdocs.cakephp.org/#TOC78831
> > > > *http://bennerweb.com/node/16(UnderstandingCakePHP Associations)
> >
> > > > HTH.
> >
> > > > > Thanks for your assistance.
> >
> > > > You're welcome.
> >
> > > > - Dardo Sordi.
> >
> > > > P/D: What I love more about CakePHP is this group, ( and the bake 
> > > > script :P )
> >
> > > > > On Dec 1, 8:04 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > > > > Hi,> I don't quite get you.
> >
> > > > > > that's probably because my English sucks! (I'm a Spanish speaker)
> >
> > > > > > > Do you mean something like this if I have a
> > > > > > > products table with fieldname: id, productname, cat_id, and I 
> > > > > > > would
> > > > > > > need a select element under the product, where I will be able to
> > > > > > > select the categories?
> >
> > > > > > > $this->set('categories', $this->Category->generateList(null, null,
> > > > > > > null, "{n}.categories.id", "{n}.categories.catname"));
> >
> > > > > > > Do I put this under the Category Controller or Products 
> > > > > > > Controller?
> >
> > > > > > If you have all associations set correctly, you can put in the
> > > > > > ProductsController:
> >
> > > > > >   $this->set('categories',
> > > > > > $this->Product->Category->generateList(null, null, null,
> > > > > > "{n}.Category.id", "{n}.Category.catname"));
> >
> > > > > > > Thanks.
> >
> > > > > > You're welcome.
> >
> > > > > > > On Dec 1, 5:41 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > > > > > > I you want to use fields from associated tables, use the 
> > > > > > > > key/valuePath
> > > > > > > > options in Model::generateList(), and set recursive to the 
> > > > > > > > apropiate
> > > > > > > > value.
> >
> > > > > > > > 2007/11/30, Dardo Sordi Bogado <[EMAIL PROTECTED]>:
> >
> > > > > > > > > This is for fields from the same table. I don't understand 
> > > > > > > > > what you
> > > > > > > > > mean with "the aro aco method".
> >
> > > > > > > > > 2007/11/30, Joyce <[EMAIL PROTECTED]>:
> >
> > > > > > > > > > Can this solution for fieldname within same table be used 
> > > > > > > > > > with those
> > > > > > > > > > that are of different tables? Or do I have to use the aro 
> > > > > > > > > > aco method
> > > > > > > > > > for that?
> >
> > > > > > > > > > Thanks.
> >
> > > > > > > > > > On Dec 1, 4:23 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> 
> > > > > > > > > > wrote:
> > > > > > > > > > > There are thre ways:
> >
> > > > > > > > > > > 1. If you are using Model::generateList(), ex:
> >
> > > > > > > > > > > //                     generateList ($conditions, $order, 
> > > > > > > > > > > $limit,
> > > > > > > > > > > $keyPath=, $valuePath)
> > > > > > > > > > > $categories = $this->Category->generateList(null, null, 
> > > > > > > > > > > null, null,
> > > > > > > > > > > '{n}.Category.catname');
> >
> > > > > > > > > > > 2. Also you can just set Model::$displayField :
> >
> > > > > > > > > > > class Category extends AppModel {
> > > > > > > > > > >   var $name = 'Category';
> > > > > > > > > > >   var $displayField = 'catname';
> >
> > > > > > > > > > > }
> >
> > > > > > > > > > > Then, it becomes:
> >
> > > > > > > > > > > $categories = $this->Category->generateList();
> >
> > > > > > > > > > > 3. You can rename colmn catname to name (default 
> > > > > > > > > > > displayField).
> >
> > > > > > > > > > > I think number 2 is best.
> >
> > > > > > > > > > > Dardo Sordi.
> >
> > > > > > > > > > > 2007/11/30, Joyce <[EMAIL PROTECTED]>:
> >
> > > > > > > > > > > > Hi all,
> >
> > > > > > > > > > > > I am a newbie in cakePHP, and I have created a table as 
> > > > > > > > > > > > per below.
> >
> > > > > > > > > > > > I have 3 fields for my categories table, and would like 
> > > > > > > > > > > > tocreatea
> > > > > > > > > > > > Select form element to insert new categories and link 
> > > > > > > > > > > > within the table
> > > > > > > > > > > > itself(where the parent_id comes from the id).
> >
> > > > > > > > > > > > Such that it will echo the select option in this manner:
> > > > > > > > > > > > <select><option value="id">catname</option></select>, 
> > > > > > > > > > > > where the values
> > > > > > > > > > > > of "id" and "catname" are populated from the table 
> > > > > > > > > > > > below.
> >
> > > > > > > > > > > > categories table:
> > > > > > > > > > > > id
> > > > > > > > > > > > catname
> > > > > > > > > > > > parent_id
> >
> > > > > > > > > > > > I have tried some of the ways that will google help, 
> > > > > > > > > > > > but none seems
> > > > > > > > > > > > successful, in which I could only end up with the id 
> > > > > > > > > > > > instead of
> > > > > > > > > > > > catname.
> >
> > > > > > > > > > > > Please advise. Thanks in advance.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to