CodeIgniter Forums
DataMapper 1.6.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DataMapper 1.6.0 (/showthread.php?tid=11358)



DataMapper 1.6.0 - El Forum - 11-11-2008

[eluser]amrnt[/eluser]
how can i make a Relation without using rated_table ??

I have (posts) table and (categories) table ..

... category has many posts ...
... posts belong to category ...

categories -
-id
-name

posts -
-id
-title
-body
-category_id

how can i make this relation with this GREAT LIBRARY (DATAMAPPER) from the begin??

thanks in advance!!!


DataMapper 1.6.0 - El Forum - 11-11-2008

[eluser]OverZealous[/eluser]
You can't. As described in the documentation, DM requires a joining table for each relationship - even one-to-one or one-to-many relationships.


DataMapper 1.6.0 - El Forum - 11-11-2008

[eluser]amrnt[/eluser]
[quote author="OverZealous.com" date="1226454356"]You can't. As described in the documentation, DM requires a joining table for each relationship - even one-to-one or one-to-many relationships.[/quote]

oh, thanks ... but what about the performance?, is it normal to use a join table ?


DataMapper 1.6.0 - El Forum - 11-11-2008

[eluser]OverZealous[/eluser]
I'm not sure what you mean by "normal". Using join tables is really a DB admin's preference. (I usually handle relationships the way you mention, but I believe the development gains in using DM out-weigh the performance differences.)

Performance depends on your database. Most databases perform joins very quickly, and you still are sending a single query to the database server.

Personally, I think PHP is going to have more of an issue performance-wise than the queries. But that's purely an opinion, not based on fact!


DataMapper 1.6.0 - El Forum - 11-11-2008

[eluser]amrnt[/eluser]
thanks man!


DataMapper 1.6.0 - El Forum - 11-13-2008

[eluser]onnyjay[/eluser]
Hi there. Great work on the datamapper however I'm having problems accessing relationships. Whenever I attempt to access a relationship I get an error message like this (this is attempting to get all related contacts for a particular client.

Code:
Unknown column 'contacts.*' in 'field list'

SELECT `contacts`.`*` FROM (`contacts`) LEFT JOIN `rel_clients_contacts` ON `contacts`.`id` = `contact_id` LEFT JOIN `clients` ON `clients`.`id` = `client_id` WHERE `clients`.`id` = 1

I have to add a select table.* to force it not to wrap the select statement

Code:
->select('*')

I would appreciate any help with this, i have searched the forums and datamapper user_guide for an answer but can't find anything.

Thanks in advance....

:-)

EDIT:
I forgot to mention that i noticed a solution posted a few pages back but it involves hacking the codeigniter > mysql_driver.php file which is not ideal.


DataMapper 1.6.0 - El Forum - 11-13-2008

[eluser]sankai[/eluser]
It's seem a bug bewteen DM1.4.5 AND CI1.7 :-S

waiting for the DM to be update.


DataMapper 1.6.0 - El Forum - 11-13-2008

[eluser]OverZealous[/eluser]
The bug is actually in CodeIgniter. If you grab the latest version of "/system/database/drivers/mysql/mysql_driver.php" from the CI subversion repository, and replace it on your version, it fixes the problem. You can download it from this link.

(I recently had to do this for a MySQL project I am working on. It's not a hack, it's a fix ;-) )


DataMapper 1.6.0 - El Forum - 11-16-2008

[eluser]onnyjay[/eluser]
Spot on.

Thats sorted it.

Ta very much for the info and link

:-)


DataMapper 1.6.0 - El Forum - 11-18-2008

[eluser]stensi[/eluser]
I'm back from Japan! Thanks for your patience :-)

I see CodeIgniter 1.7.0 was released while I was away and I understand there was a bug in it to do with the protected identifiers that has since been fixed in the SVN. I was hoping CodeIgniter 1.7.1 would have been released with this fix in it, before my return, but I guess there weren't enough fixes to warrant another release so soon. Oh well, I'll just add instructions in the DM User Guide on how to install the fixed MySQL Driver until the fixed version is in the standard CI download.

I've got a fair few things to do as far as settling back in at home goes but I'll be starting work on the next version of DataMapper very soon. One of the main things will be to use the new Form Validation class instead of the now deprecated Validation class (I'd already just about finished that before leaving, using the pre-released SVN version).

I also need to read back several pages worth of comments to catch up on the discussion. I'll give updates again soon. Right now, I'm off to bed. Had an 11 hours overnight flight, on which I didn't sleep a wink, so I need to catch up on my sleep too! ;-)