Gostaria de saber como faço para fazer select personalizada exemplo: select count(o) from MinhaClass o where o.nome like '%x%'
Comment #1
Posted on Jul 16, 2009 by Grumpy HorseSorry, I don't know any spanish ^^ I guess you want OQL? Sorry, I surely won't write an OQL parser in PHP ;) But the feature for the next release will be filter object support, so you can write: MinhaClass::getByFilter($db, array(new DataFilterElement(MinhaClass::FIELD_NOME, DataFilterElement::CONTAINS, 'x')));
Cheers ^^
Comment #2
Posted on Jul 16, 2009 by Swift KangarooI speak Portuguese in Brazil is not Spanish ... ^^
I wonder how to select a personal example: select count (o) from the MinhaClass where o.nome like '% x%'
Note: I would like to thank the great initiative ...
Comment #3
Posted on Jul 16, 2009 by Grumpy HorseI speak Portuguese in Brazil is not Spanish Sorry, my bad :)
Sorry, but the OQL example you provided will never be implemented by myself.
At the moment the whole thing is much too simple to be good ^^ Query by example/filter will only match exact values. Right now you'd have to write your own code do realise the example you posted.
I'm working on filter objects though, which would be a bit more flexible for matching (hopefully finished next week or so).
But counting like in your example would still be a better idea in to do in SQL directly, as my projects goal is to provide Entitiy classes which allow easy fetching / updating and inserting for OOP code, and thus would involve fetching all matched rows as objects and then counting them. Since that would be rather inefficient (especially in PHP), well, ... not a good idea :)
I'm sorry, my english isn't very good, I hope I've answered the right question ^^
And your welcome :)
Comment #4
Posted on Jul 16, 2009 by Grumpy HorseComment deleted
Comment #5
Posted on Jul 17, 2009 by Swift KangarooBut you have implemented some method where I can pass this sql and thus get the result you desire. I understand the situation of your project but I would like to know if I can do this using the select model because you implemented using java you can use a generic method that is more specific searches. Because not yet learned to use all the features you implemented and would like to know if you could help me. I guarantee that many people go through this difficulty IRAM too.
Note: It would be an interesting documentation with examples of all methods that you created this very helpful.
Do not understand your suggestion could make an example.
Comment #6
Posted on Jul 17, 2009 by Grumpy HorseVersion 1.2.4 is out which allows filters. Download the NetBeans pluin, upgrade, regerenate your Class (you have to delete/rename it first). You'll also need the source package which contains the DCF.class.php.
To implement your example: $db=new PDO('mysql:dbname=yourdb;host=localhost', 'user', 'passwd'); include_once 'DFC.class.php'; echo count( MinhaClass::getByFilter( $db, array( new DFC(MinhaClass::FIELD_NOME, 'x', DFC::CONTAINS) // new filter on field nome, where the value contains x ) ) );
Examples and explainations will be coming next week (updated the HOWTO a time bit)... sry, yesterday was my birthday and I intend to pary till sunday :P have fun ^^
Comment #7
Posted on Jul 17, 2009 by Grumpy Horse(No comment was entered for this change.)
Comment #8
Posted on Jul 17, 2009 by Swift KangarooCongratulations on your anniversary and thanks for the help I download and test the new version ... have a good rest ...
Comment #9
Posted on Jul 20, 2009 by Grumpy HorseOk, I've released 1.2.5. It contains a bit of what you could consider 'examples' in the test folder (in the source package). I've also started a wiki page for the relevant generated methods: http://code.google.com/p/db2php/wiki/GeneratedMethods .
Could you do be a favor and tell me which parts aren't clear from the PHPDoc and the examples. Or any questions you have left. I always find it a bit hard to write good doc for my own code ^^
Thanks
Status: Started
Labels:
Type-Task
Priority-Low