There seems to be two styles of folder structure in the core Magento when it comes to resources. There are quite a lot using the mysql4 folder and other simple using Resource folder.
I.e. install script would live here: Mycompany_Mymodule_Model_Resource_Setup.
Is there a reason for this, legacy or otherwise - or is this simply a coding style between different core developers?
First: Magento's folder structure exists only because of its autoloader's implementation. If you try to derive too much meaning from where a file is placed in Magento you'll go mad, and different modules seem to follow different conventions. The autoloader will look for
Mage_Core_Model_Foo_Bar
in
Mage/Core/Model/Foo/Bar.php
So I'll be talking about naming conventions below, which will indirectly address why a file is in a particular folder.
Originally all database resource were named with the Mysql4
convention. I've talked to a few of the original developers, and the intention was to denote that the resource was for the then "standard" Mysql 4 database. If a resource used a specific feature of say, Mysql 5, then they'd have used a Mysql5
convention.
As Magento Inc. went through the usual startup churn and other developers took over where the original developers left off, the thinking changed on this. The Magento 1.6 release, which laid the groundwork for Enterprise Edition's support of multiple RDBMS, altered how these resources worked and were named.
Backwards compatibility was maintained, but most of the old Mysql4
resources were renamed to use the generic Resource
, and a new method for multiple RDBMS support was introduced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With