DataMapper ORM v1.8.0 |
[eluser]WanWizard[/eluser]
I would do something like Code: class Category extends DataMapper { Note, this would require a foreign key called "parent_category_id".
[eluser]Spir[/eluser]
[quote author="WanWizard" date="1306106069"]I would do something like Code: class Category extends DataMapper { Note, this would require a foreign key called "parent_category_id".[/quote] So you mean this : Code: CREATE TABLE IF NOT EXISTS `categories` ( Instead of what I previously said : Code: CREATE TABLE IF NOT EXISTS `categories` (
[eluser]WanWizard[/eluser]
From the top of my head: yes. I'm not in a position to test it at the moment... (and don't forget the AUTOINCREMENT in the 'id' column).
[eluser]Julio Fagundes[/eluser]
My cache (simplecache) is not being created. Here my config: config/datamapper.php Code: $config['production_cache'] = 'datamapper/cache'; // THIS CACHE IS OK. controller/clientes.php Code: $r = new Cliente(); In output profiler, i see this large query every time. *the folder is writable Is there something wrong? or missing?
[eluser]WanWizard[/eluser]
Simplecache is, as the name implies, is an extremely simple cache extension. So simple, that it isn't more than basically a wrapper around CI's database caching methods, $this->db->cache_on() / $this->db->cache_off() to be exact. This also means you need to configure CI properly to get this to work. As the manual states: the production_cache setting has nothing to do with query caching.
[eluser]Julio Fagundes[/eluser]
Yes, I know the production cache is a particular cache to datamapper. My question was if there is something wrong, because no file is created. Thanks to reply, do you know what is the best way to do cache with datamapper?
[eluser]WanWizard[/eluser]
As I said, you need to configure CI database caching, Datamapper just uses that. See http://ellislab.com/codeigniter/user-gui...ching.html
[eluser]Julio Fagundes[/eluser]
Solved. config/database.php Code: $db['default']['cachedir'] = ''; // needs to be a absolute path
[eluser]Arministrator[/eluser]
I need some pointers on accessing relations. I did study the docs and examples, and I have a solution that kind of works, but I feel I overcomplicated and would really like to keep the code smart as possible. This is my first use of DataMapper. these are the tables and relations i got (it's a blood bank app): donators donations bloodypes bloodtypes_donators bloodtypes_donations donations_donators Donor model $has_one bloodtype, $has_many donation Donation model $has_many donor, bloodtype Blootype model $has_many donor, donation I think my relations are ok, but check those too, please. I want to be able to read all the donations (without donors), all donations by bloodtype, all donations with all donors, and all donations by donor id. So here's what I came up with, mostly following the example in DataMappers bugs app. This instatiates a donator and gets all his donations (only created field), and gets the count of all donations related to that user. At least it's supposed to. Code: $donator = new Donator(); Thanks a lot. |
Welcome Guest, Not a member yet? Register Sign In |