nciri / zend-db-model-generator

Automatically exported from code.google.com/p/zend-db-model-generator
0 stars 0 forks source link

Fix for autoclass loading using a table with a many-to-many relationship and zend_loader #34

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

Im kinda new to PHP and Zend but I hope this may of some use.

When I was trying to delete a Model_<'Random Object'> I stumbled upon an error. 
Zend_Loader::loadClass(); was giving a " Warning: include_once(<'Random 
Object'>.php): failed to open stream: ".

After some searching I noticed that during a delete Zend_Db_Table_Abstract will 
check if there are any dependent tables, and will use Zend_Loader::loadClass() 
to load the class. To load the class its using the $_dependentTables in the 
generated Model_DbTable_<'Random Object'>.

The String added to the $_dependentTables array was <'Random Object'> and was 
missing the namespaces/prefixes (or how its called in Zend^^).
By adding the namespaces (like "Model_DbTable_<'Random Object'>") the error was 
fixed.

I hope this will be of some use. 

Thank you for this nice generator. It saved me lots of work.
Best regards
S. Choo

(Any tips on how to report issues are always welcome )

Original issue reported on code.google.com by StevenChoo.NL on 17 Apr 2013 at 11:23

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Here is a fix which works for me and MySQL...Don't know what would happen with 
the other db generators.

Updating class/MakeDbTable.php puts this namespace change into the generated 
code...
Hope it helps someone.
#diff
514c514
<           $dependents[] = $this->_getClassName($info['foreign_tbl_name']);
---
>           $dependents[] = $info['tbl_name'];

Original comment by cruses...@gmail.com on 22 Apr 2014 at 7:44