Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - module conventions mysql4 or resource

Tags:

magento

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?

like image 493
Marty Wallace Avatar asked Apr 03 '12 20:04

Marty Wallace


1 Answers

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.

like image 149
Alan Storm Avatar answered Nov 14 '22 05:11

Alan Storm