Re: DB_DataObject link problem (Does DB_DataObject try to set up auto links?)

From: Date: Tue, 22 Mar 2005 18:49:02 +0000
Subject: Re: DB_DataObject link problem (Does DB_DataObject try to set up auto links?)
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18238@lists.php.net to get a copy of this message
hi there for some reason my whole message didn't get posted here it is again: Here's the situation. I have DB_DataObject 1.7.11 I have a couple of tables I'm trying to link: products +-----------------+----------------------+------+-----+---------+----------------+
| Field           | Type                 | Null | Key | Default | Extra          |
+-----------------+----------------------+------+-----+---------+----------------+
| id              | int(10) unsigned     |      | PRI | NULL    | auto_increment |
| catalog_id      | smallint(5) unsigned |      |     | 0       |          |
| application     | varchar(255)         |      |     |         |          |
| note            | text                 |      |     |         |          |
| catalogNote     | text                 |      |     |         |          |
+-----------------+----------------------+------+-----+---------+----------------+ catalogs +---------+---------------------+------+-----+---------+----------------+
| Field   | Type                | Null | Key | Default | Extra          |
+---------+---------------------+------+-----+---------+----------------+
| id      | tinyint(3) unsigned |      | PRI | NULL    | auto_increment |
| catalog | varchar(255)        |      |     |         |                |
+---------+---------------------+------+-----+---------+----------------+ So I created a links.ini file that looks like this: [catalogs] id = products:catalog_id [products] catalog_id = catalogs:id I'm not sure if I should link both of the tables to each other but I tried just one or the other and had the same results. Anyway when I try to do some linking: $product->get(1); $product->getLinks(); I get no links. I turned on debugging and here are some of the highlights: dataobjects_products: databaseStructure: Missing ini file: /htdocs/test.lan/maval_catalog_admin/includes/DataObjects/maval_catalog_new.ini dataobjects_products: databaseStructure: Missing links.ini file: /htdocs/test.lan/maval_catalog_admin/includes/DataObjects/maval_catalog_new.links.ini . . . Note: We successfully load a product but when we try to get any links . . . dataobjects_products: ERROR: autoload:Could not find class DataObjects_Catalog using class_location value dataobjects_products: ERROR: factory could not find class from catalog dataobjects_products: ERROR: getLink:Could not find class for row catalog_id, table catalog Note: maval_catalog_new is the name of the database. Note: I think the above lines are just saying that "it was missing an ini file and then it found it". What has me confused is why it would be trying to find the DataObjects_Catalog class. It should be 'catalogs' not 'catalog', the class DataObject_Catalogs does exist. Why would it be looking for DataObject_Catalog? I have checked my code several times and no where in the code (or any of the ini files) do I refer to a "catalog" table or class. It's always "catalogs". My guess is DB_DataObjects is trying to be helpful and if I format my table names and columns just right then I don't have to create a links.ini file and everything just works. I'm not sure about this though. I didn't see anything in the documentation about DB_DataObject being able to do that. So if I'm right is there a way to make DB_DataObject use my links.ini file instead? If I'm wrong what else could be going on? I'd be happy to provide any other info I may have left out. Also I'm just curious if anyone has a tried a true SQL naming scheme or basic guide lines that work well with DB_DataObject? Before I started using DB_DataObject I have always used plural names for my tables name and singular names for the columns, but if that's just going to make my life harder then I should probably change my ways. thanks -jachin

« previous php.pear.general (#18238) next »