DataMapper ORM v1.8.1 |
[eluser]tarciozemel[/eluser]
Limit with range dynamically Hi, people! If I use Code: $limit = 9; Everything runs fine and the generated query is OK. But, if I use Code: $limit = '9,9'; The generated query not contains the LIMIT part! Any ideas about how about I can pass range values in limit with DM? Regards!
[eluser]tarciozemel[/eluser]
OK, I already see my mistake: "9,9" it's just 1 param and the function needs 2. If WanWizard judging this is good, the limit function can be changed to: Code: /** Regards!
[eluser]smi23[/eluser]
Hi everyone! I have a little problem with auto populating: My global config variable Code: $config['auto_populate_has_many'] = FALSE; So I add this line to the Country model: Code: var $auto_populate_has_many = TRUE; Strange, but if global variable is TRUE everything is OK. Big thanks for any response.
[eluser]WanWizard[/eluser]
Which version are you using? You're posting in the 1.8.1 thread which is no longer the current version. There was an issue with overriding global config values in the model which has been fixed. So I suggest you upgrade to the latest version from Bitbucket first and see if that fixes it.
[eluser]John Murowaniecki[/eluser]
Gentlemans, I know that is my fault but I cannot see any solution more - yes, before went here I've searched almost all this topic, the user guide, the documention and other foruns, so I'm very tired and blind or this way is "correct". Well, let me explain the whole picture: I have a model that has many votes and one profile information. There is the relations: Code: class Cadastro extends DataMapper ..Basicly everything works fine - including this problematic query - with few registries.. But with many (at least 20k of new_memes and 800k of new_votes) it freezes. Code: $memes = new Meme(); Everything is ok, except for the sloooooOooo..oowest query generated: Code: SELECT `new_memes`.* Well.. If we cut off the LEFT OUTHER JOIN from the subquery we made this more than 20x faster (at least doesn't brick the site). So this is the optimized query: Code: SELECT `new_memes`.* ..The problem is: I can't realise the query $writed->like_this()->way(1). And I need a faster query (if possible). Owyeah: I'm already using the CI cache and sorry, but I didn't see any way to resolve this without asking you. So how can I resolve this? There's an easy way? Should I create a view for this? Or manage cached queries? Or anything else? Thanks in advance.
[eluser]WanWizard[/eluser]
Instead of using include_related_count(), create the subquery manually on a separate object, and add that to the main query. See http://datamapper.wanwizard.eu/pages/subqueries.html on how to create and use subqueries.
[eluser]smi23[/eluser]
[quote author="WanWizard" date="1333990389"]Which version are you using? You're posting in the 1.8.1 thread which is no longer the current version. There was an issue with overriding global config values in the model which has been fixed. So I suggest you upgrade to the latest version from Bitbucket first and see if that fixes it.[/quote] Thanks for the reply. Sorry, missed the topic name. My version is 1.8.2 (taken from https://bitbucket.org/wanwizard/datamapp..._1.8.2.zip ). I have also noticed that if I comment this line in a config file Code: $config['auto_populate_has_many'] = FALSE;
[eluser]WanWizard[/eluser]
That is not the latest version, the bugfix for this was after that (tagged 1.8.2.1). Change line 485 to read Code: if ( ! property_exists($this, $config_key))
[eluser]smi23[/eluser]
[quote author="WanWizard" date="1334051260"]That is not the latest version, the bugfix for this was after that (tagged 1.8.2.1). Change line 485 to read Code: if ( ! property_exists($this, $config_key)) Yes, that was a problem. Thanks for help, and BIG thanks for DM!
[eluser]John Murowaniecki[/eluser]
[quote author="WanWizard" date="1334008176"]Instead of using include_related_count(), create the subquery manually on a separate object, and add that to the main query. See http://datamapper.wanwizard.eu/pages/subqueries.html on how to create and use subqueries.[/quote] ..Well, may I say that now I know how to optimize subqueries ^__^ ..Unfortunately this did not help me as expected (that is the great problem of creating expectations about something), but I do not see optimally perform this procedure (yes, I create a view to work with it and there was not much faster). But here's the solution that we chose to use: keep making records usually vote, but every time someone votes I update the record of voting with the counting of votes.. Dudes, that made the queries rather rapidly slipping in butter (: I thank heartily all the help I have received here. Seriously. But I would say that, sometimes, the best solution to a given problem is too ridiculous to even be considered. I'm sorry if my solution is too stupid for you. (; |
Welcome Guest, Not a member yet? Register Sign In |