Reputation: 3
I am using the below code to connect to the database in the module to write the several database queries which are not correct it seems, so please tell me what is the correct way of connecting to the database from the new module.
$con = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
mysql_select_db(_DB_NAME_);
Upvotes: 0
Views: 886
Reputation: 3349
Please, before read this guidelines to create a new module: How to create a module
And then this: Best practices of the Db Class
Including the files like the elPresta
says it's old and deprecated method, after that to make a simple query, read what he wrote Matteo Enna
.
Upvotes: 0
Reputation: 648
Just include these files and thats it!
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
And after all you can use methods as Matteo told u. Or read more here ( http://doc.prestashop.com/display/PS15/DB+class+best+practices )
Upvotes: 0
Reputation: 1301
use
$query ="select * from name_table"; /*example query*/
Db::getInstance()->executeS($query);
you do not need anything else to make a query
Upvotes: 1