ColdDistance Posted June 26, 2013 Share Posted June 26, 2013 Hi, I'm trying to build a personal module to manage returns and I want to make a HTML select with the orders and their customers. I need to know what is the variable or object to connect with the database because I do a SQL query in my PHP script, but I don't know how to do the connection to database. Link to comment Share on other sites More sharing options...
presta4you.com Posted June 26, 2013 Share Posted June 26, 2013 Check this link: http://doc.prestashop.com/display/PS15/DB+class+best+practices Link to comment Share on other sites More sharing options...
vekia Posted June 26, 2013 Share Posted June 26, 2013 use the Db object, you can use static getInstance() function for example: Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS("SELECT * FROM `"._DB_PREFIX_."products"); Link to comment Share on other sites More sharing options...
ColdDistance Posted June 27, 2013 Author Share Posted June 27, 2013 Thank you for your answers, I hope they will be useful. Link to comment Share on other sites More sharing options...
vekia Posted June 27, 2013 Share Posted June 27, 2013 i forgot to mention about little modification for INSERT / UPDATE / DELETE queries: in these cases you have to use execute function instead the executeS example: Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'something` (row) VALUES (value)'); Link to comment Share on other sites More sharing options...
ColdDistance Posted June 27, 2013 Author Share Posted June 27, 2013 Thanks, the query is for the select HTML tags. For create or update orders I use stored procedures. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now