PrestaShopCorp / yousticeresolutionsystem

Other
1 stars 3 forks source link

Local.php & database #6

Closed gaillafr closed 10 years ago

gaillafr commented 10 years ago

You cannot create your own class, you have to use the classes & methods given by the core, i.e: Db::getInstance()->execute(...);

devyoustice commented 10 years ago

we can not use PrestaShop's internal database classes in the generic SDK. It's OK?

devyoustice commented 10 years ago

We can leverage prestashop's API to get hold of a connection object (instead generting one ourselves). and provide that to our generic Library. Using presta-specific code inside our generic lib does not really make sense, does it?

prestachris commented 10 years ago

Here is a simple workaround that could help you:

  1. Remove $y_api->setDbCredentials($db); and
    $db = array( 'driver' => 'mysql', 'host' => _DBSERVER, 'user' => _DBUSER, 'pass' => _DBPASSWD, 'name' => _DBNAME, 'prefix' => _DBPREFIX ); in the main module file
  2. In the SDK, where the connection is made, you simply need to get the PDO object (and the rest of your code could stay unchanged).

To do so, it's very easy:

$pdo_from_prestashop = new DbPDO(); $pdo_from_prestashop->connect(); $pdo = $pdo2->link;

You probably need to include config.inc.php and init.php to make sure DbPDO would be recognized by our autoload and for the database connection to be initiated.

devyoustice commented 10 years ago

Check the newly pushed version, commit: f9cf09425986ed30c9b14b35627d8f8e47d5d35f or later