Version Notes
Support for Magento 1.6 CE
Download this release
Release Info
Developer | Subesh Pokhrel |
Extension | Sp_Edb |
Version | 1.2.2 |
Comparing to | |
See all releases |
Version 1.2.2
- app/code/community/Sp/Edb/Helper/Data.php +12 -0
- app/code/community/Sp/Edb/Model/Abstract.php +40 -0
- app/code/community/Sp/Edb/Model/Comments.php +10 -0
- app/code/community/Sp/Edb/Model/Connection.php +78 -0
- app/code/community/Sp/Edb/Model/Mysql4/Abstract.php +25 -0
- app/code/community/Sp/Edb/Model/Mysql4/Collection/Abstract.php +22 -0
- app/code/community/Sp/Edb/Model/Mysql4/Comments.php +10 -0
- app/code/community/Sp/Edb/Model/Mysql4/Comments/Collection.php +12 -0
- app/code/community/Sp/Edb/etc/config.xml +56 -0
- app/code/community/Sp/Edb/etc/system.xml +57 -0
- app/etc/modules/Sp_Edb.xml +9 -0
- package.xml +22 -0
app/code/community/Sp/Edb/Helper/Data.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* External Database connection in Magento
|
4 |
+
*
|
5 |
+
* @author Subesh Pokhrel
|
6 |
+
* @package Sp_Edb
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class Sp_Edb_Helper_Data extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
}
|
app/code/community/Sp/Edb/Model/Abstract.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* External Database connection in Magento
|
4 |
+
*
|
5 |
+
* @author Subesh Pokhrel
|
6 |
+
* @package Sp_Edb
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Sp_Edb_Model_Abstract extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/* @var Sp_Edb_Model_Connection */
|
14 |
+
protected $_externalConnection;
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
$this->_externalConnection = Mage::getModel('edb/connection');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Gets the External Connection Model
|
23 |
+
*
|
24 |
+
*@return Sp_Edb_Model_Connection
|
25 |
+
*/
|
26 |
+
public function getExternalConnection()
|
27 |
+
{
|
28 |
+
return $this->_externalConnection;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getExternalReadConnection()
|
32 |
+
{
|
33 |
+
return $this->_externalConnection->getConnectionName();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getExternalWriteConnection()
|
37 |
+
{
|
38 |
+
return $this->_externalConnection->getConnectionName();
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Sp/Edb/Model/Comments.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sp_Edb_Model_Comments extends Sp_Edb_Model_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->_init('edb/comments');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Sp/Edb/Model/Connection.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* External Database connection in Magento
|
4 |
+
*
|
5 |
+
* @author Subesh Pokhrel
|
6 |
+
* @package Sp_Edb
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Sp_Edb_Model_Connection
|
11 |
+
{
|
12 |
+
const XML_CONFIG_EDB_HOST = 'edb_settings/dbconnection/host';
|
13 |
+
const XML_CONFIG_EDB_DBNAME = 'edb_settings/dbconnection/dbname';
|
14 |
+
const XML_CONFIG_EDB_USERNAME = 'edb_settings/dbconnection/username';
|
15 |
+
const XML_CONFIG_EDB_PASSWORD = 'edb_settings/dbconnection/password';
|
16 |
+
|
17 |
+
const EXTERNAL_RESOURCE_NAME = 'edb_connection';
|
18 |
+
|
19 |
+
/*@var array */
|
20 |
+
protected $_config;
|
21 |
+
|
22 |
+
/*@var Varien_Db_Adapter_Pdo_Mysql */
|
23 |
+
protected $_connection;
|
24 |
+
|
25 |
+
public function __construct()
|
26 |
+
{
|
27 |
+
$this->_setConnection();
|
28 |
+
}
|
29 |
+
/**
|
30 |
+
* Gets the Config Settings in the Admin Settings for DB Connection
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getConfig()
|
34 |
+
{
|
35 |
+
if (!$this->_config) {
|
36 |
+
$this->_config = array();
|
37 |
+
// Setting the Values from the Admin Config
|
38 |
+
$this->_config['host'] = Mage::getStoreConfig(self::XML_CONFIG_EDB_HOST);
|
39 |
+
$this->_config['dbname'] = Mage::getStoreConfig(self::XML_CONFIG_EDB_DBNAME);
|
40 |
+
$this->_config['username'] = Mage::getStoreConfig(self::XML_CONFIG_EDB_USERNAME);
|
41 |
+
$this->_config['password'] = Mage::getStoreConfig(self::XML_CONFIG_EDB_PASSWORD);
|
42 |
+
|
43 |
+
// Setting the default Values
|
44 |
+
$this->_config['initStatements'] = 'SET NAMES utf8';
|
45 |
+
$this->_config['model'] = 'mysql4';
|
46 |
+
$this->_config['type'] = 'pdo_mysql';
|
47 |
+
$this->_config['pdoType'] = '';
|
48 |
+
$this->_config['active'] = '1';
|
49 |
+
}
|
50 |
+
return $this->_config;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Gets External DB Connection Resource
|
55 |
+
*
|
56 |
+
* @return Varien_Db_Adapter_Pdo_Mysql
|
57 |
+
*/
|
58 |
+
public function getConnection()
|
59 |
+
{
|
60 |
+
if (!$this->_connection) {
|
61 |
+
$this->_setConnection();
|
62 |
+
}
|
63 |
+
return $this->_connection;
|
64 |
+
}
|
65 |
+
|
66 |
+
private function _setConnection()
|
67 |
+
{
|
68 |
+
if (!$this->_connection) {
|
69 |
+
$this->_connection = Mage::getSingleton('core/resource')->createConnection(self::EXTERNAL_RESOURCE_NAME, 'pdo_mysql', $this->getConfig());
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
public static function getConnectionName()
|
74 |
+
{
|
75 |
+
return self::EXTERNAL_RESOURCE_NAME;
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
app/code/community/Sp/Edb/Model/Mysql4/Abstract.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* External Database connection in Magento
|
4 |
+
*
|
5 |
+
* @author Subesh Pokhrel
|
6 |
+
* @package Sp_Edb
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Sp_Edb_Model_Mysql4_Abstract extends Mage_Core_Model_Mysql4_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function _getConnection($connectionName)
|
19 |
+
{
|
20 |
+
//What Ever the Connection Name read or write we use the same connection name for everyting
|
21 |
+
$connection =$this->_resources->getConnection(Sp_Edb_Model_Connection::EXTERNAL_RESOURCE_NAME);
|
22 |
+
return $connection;
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/community/Sp/Edb/Model/Mysql4/Collection/Abstract.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* External Database connection in Magento
|
5 |
+
*
|
6 |
+
* @author Subesh Pokhrel
|
7 |
+
* @package Sp_Edb
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Sp_Edb_Model_Mysql4_Collection_Abstract extends Mage_Core_Model_Mysql4_Collection_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
$this->_construct();
|
17 |
+
// Setting the Connection
|
18 |
+
$read = $this->getResource()->getReadConnection();
|
19 |
+
$this->setConnection($read);
|
20 |
+
$this->_initSelect();
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Sp/Edb/Model/Mysql4/Comments.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sp_Edb_Model_Mysql4_Comments extends Sp_Edb_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('edb/comments', 'comment_ID');
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
app/code/community/Sp/Edb/Model/Mysql4/Comments/Collection.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Sp_Edb_Model_Mysql4_Comments_Collection extends Sp_Edb_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Local constructor
|
6 |
+
*
|
7 |
+
*/
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
$this->_init('edb/comments');
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Sp/Edb/etc/config.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Sp_Edb>
|
5 |
+
<version>1.2.0</version>
|
6 |
+
</Sp_Edb>
|
7 |
+
</modules>
|
8 |
+
<adminhtml>
|
9 |
+
<acl>
|
10 |
+
<resources>
|
11 |
+
<all>
|
12 |
+
<title>Allow Everything</title>
|
13 |
+
</all>
|
14 |
+
<admin>
|
15 |
+
<children>
|
16 |
+
<system>
|
17 |
+
<children>
|
18 |
+
<config>
|
19 |
+
<children>
|
20 |
+
<edb_settings>
|
21 |
+
<title>EDB Settings</title>
|
22 |
+
</edb_settings>
|
23 |
+
</children>
|
24 |
+
</config>
|
25 |
+
</children>
|
26 |
+
</system>
|
27 |
+
</children>
|
28 |
+
</admin>
|
29 |
+
</resources>
|
30 |
+
</acl>
|
31 |
+
</adminhtml>
|
32 |
+
<global>
|
33 |
+
<models>
|
34 |
+
<edb>
|
35 |
+
<class>Sp_Edb_Model</class>
|
36 |
+
<resourceModel>edb_mysql4</resourceModel>
|
37 |
+
</edb>
|
38 |
+
<edb_mysql4>
|
39 |
+
<class>Sp_Edb_Model_Mysql4</class>
|
40 |
+
<entities>
|
41 |
+
<!-- Add As many tables config here -->
|
42 |
+
<comments>
|
43 |
+
<table>wp_comments</table>
|
44 |
+
</comments>
|
45 |
+
<!-- Add As many tables config here -->
|
46 |
+
</entities>
|
47 |
+
</edb_mysql4>
|
48 |
+
</models>
|
49 |
+
<helpers>
|
50 |
+
<edb>
|
51 |
+
<class>Sp_Edb_Helper</class>
|
52 |
+
</edb>
|
53 |
+
</helpers>
|
54 |
+
</global>
|
55 |
+
|
56 |
+
</config>
|
app/code/community/Sp/Edb/etc/system.xml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<edb_tab translate="label" module="edb">
|
5 |
+
<label>Sp EDB</label>
|
6 |
+
<sort_order>500</sort_order>
|
7 |
+
</edb_tab>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<edb_settings translate="label" module="edb">
|
11 |
+
<label>External Database Connection</label>
|
12 |
+
<tab>edb_tab</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>1000</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>0</show_in_website>
|
17 |
+
<show_in_store>0</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<dbconnection translate="label" module="edb">
|
20 |
+
<label>Database Host Settings</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort>1000</sort>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>0</show_in_website>
|
25 |
+
<show_in_store>0</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<host translate="label,comment" module="edb">
|
28 |
+
<label>Database Host</label>
|
29 |
+
<comment>Host of the Database Server</comment>
|
30 |
+
<frontend_type>text</frontend_type>
|
31 |
+
<sort_order>1</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
</host>
|
34 |
+
<dbname translate="label,comment" module="edb">
|
35 |
+
<label>Database Name</label>
|
36 |
+
<frontend_type>text</frontend_type>
|
37 |
+
<sort_order>1</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
</dbname>
|
40 |
+
<username translate="label,comment" module="edb">
|
41 |
+
<label>User Name</label>
|
42 |
+
<comment>User Name of the Database Server</comment>
|
43 |
+
<frontend_type>text</frontend_type>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
</username>
|
46 |
+
<password translate="label,comment" module="edb">
|
47 |
+
<label>Password</label>
|
48 |
+
<frontend_type>password</frontend_type>
|
49 |
+
<comment>Password of the Database Server</comment>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
</password>
|
52 |
+
</fields>
|
53 |
+
</dbconnection>
|
54 |
+
</groups>
|
55 |
+
</edb_settings>
|
56 |
+
</sections>
|
57 |
+
</config>
|
app/etc/modules/Sp_Edb.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Sp_Edb>
|
5 |
+
<codePool>community</codePool>
|
6 |
+
<active>true</active>
|
7 |
+
</Sp_Edb>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Sp_Edb</name>
|
4 |
+
<version>1.2.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This is a external DB connector module. This will help in connecting to external databases other than Magento's Database.</summary>
|
10 |
+
<description>This is a external DB connector module. This will help in connecting to external databases other than Magento's Database.
|
11 |
+

|
12 |
+

|
13 |
+

|
14 |
+
This supports both read and write connection. Using this module you don't have to worry about making connections just use the Magento standard Model Object creation and getting collections.</description>
|
15 |
+
<notes>Support for Magento 1.6 CE</notes>
|
16 |
+
<authors><author><name>Subesh Pokhrel</name><user>subesh</user><email>subesh.pokharel@javra.com</email></author></authors>
|
17 |
+
<date>2012-02-10</date>
|
18 |
+
<time>11:51:03</time>
|
19 |
+
<contents><target name="magecommunity"><dir name="Sp"><dir name="Edb"><dir name="Helper"><file name="Data.php" hash="9c4c64b4e2f7f5256e8e68d09c6a3f5a"/></dir><dir name="Model"><file name="Abstract.php" hash="a1d99b2b026ee88c6de2d38668659163"/><file name="Comments.php" hash="38b114cdb566f0f02f1725b93d369b47"/><file name="Connection.php" hash="aa43ffa64c5cc414a06291358dbebbdf"/><dir name="Mysql4"><file name="Abstract.php" hash="840d77700a2d7a1c793c8ae6d4df6ca6"/><dir name="Collection"><file name="Abstract.php" hash="53d5f699280d81370aee876941aa5e20"/></dir><dir name="Comments"><file name="Collection.php" hash="5136d814ae35a4c2703da0ca1b22fd4a"/></dir><file name="Comments.php" hash="b45c5b4c3653feb046f4221651d9fc2e"/></dir></dir><dir name="etc"><file name="config.xml" hash="8aa5624fdcf6d6e5c5f54d995f332620"/><file name="system.xml" hash="f972154aa0fd3bd817166b031b3dba4b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sp_Edb.xml" hash="95d3d4b3e83657e0e148806b0bd81da4"/></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
+
</package>
|