Hello,
Today I tried a simple case to test php code generation with DBVA but I had a problem with EZOQL queries. Let us considering the attached class diagram.
So we have a “Product” which can be associated to a “Category”
I have no problem when I generate php code and when I use the sample files.
Now, I tried to write a EZOQL query in order to retrieve products associated to a specified category. So this is something like this :
$m = epManager :: instance();
$sql="From Product as p where p.category.iD=1";
$products = $m->query($sql);
But it returns the following error :
Fatal error: Uncaught exception ‘epExceptionDbAdodb’ with message 'Cannot execute query: mysql error: [1146: Table ‘test._ezpdo_relation_category_product’ doesn’t exist] in EXECUTE(“SELECT DISTINCT p.* FROM Product AS p LEFT JOIN _ezpdo_relation_category_product AS _1 ON _1.var_a = ‘category’ AND (_1.class_a = ‘Product’ AND _1.oid_a = p.eoid) LEFT JOIN Category AS _2 ON _1.base_b = ‘Category’ AND _1.class_b = ‘Category’ AND _1.oid_b = _2.eoid WHERE _2.ID=1”) ’ in D:\xampp\htdocs\test\lib\phporm\src\db\epDbAdodb.php:188 Stack trace: #0 D:\xampp\htdocs\test\lib\phporm\src\db\epDb.php(352): epDbAdodb->_execute(‘SELECT DISTINCT…’) #1 D:\xampp\htdocs\test\lib\phporm\src\db\epDbObject.php(3526): epDb->execute(‘SELECT DISTINCT…’) #2 D:\xampp\htdocs\test\lib\phporm\src\db\epDbObject.php(2129): epDbObject->_execute(‘SELECT DISTINCT…’) #3 D:\xampp\htdocs\test\lib\phporm\src\db\epDbObject.php(2106): epDbObject->_queryObjects(Array, Array, Array, false) #4 D:\xampp\htdocs\test\lib\phporm\src\runtime\epManager.php(610): epDbObje in D:\xampp\htdocs\test\lib\phporm\src\db\epDbAdodb.php on line 188
Indeed the table ‘_ezpdo_relation_category_product’ doesn’t exist in the database. I looked at the source code and I noticed that you have commentted some lines (particularly in epDbObject.php) in order not to use a relation table.
So I would like to know if there is a bug or if I forgot something which makes it not functionning. Or maybe there is another way to write my query??
Thanks
testCase.jpg