Accounts Posted August 27, 2010 Share Posted August 27, 2010 What is the safest way to do SQL queries on my own Presta Shop database on header.tpl? Currently I have been doing: {php} $username = 'username'; $password = 'pass'; mysql_connect("localhost", $username, $password) or die(mysql_error()); mysql_select_db("shop") or die(mysql_error()); {/php} in my header.tpl, but I feel there is another way and more safer way, but I'm not sure how to access the database from the config files. Link to comment Share on other sites More sharing options...
Callio Posted August 27, 2010 Share Posted August 27, 2010 I am having similar issues. There are probably a few ways to go about. I will do some more research.Jim Link to comment Share on other sites More sharing options...
MrBaseball34 Posted September 1, 2010 Share Posted September 1, 2010 What exactly are you trying to do in the header? Link to comment Share on other sites More sharing options...
Accounts Posted September 1, 2010 Author Share Posted September 1, 2010 Generate lists of categories and such on a nav bar. I know there is a module for this, but it does not suit my needs and hence I made my own nav bar using jkmegamenu in the header.tpl and want a query to list all the categories and manufacturers.Refer to this topic I made awhile ago:http://www.prestashop.com/forums/viewthread/66076/general_discussion/solvedadding_categories_and_manufacturers_to_a_drop_down Link to comment Share on other sites More sharing options...
MrBaseball34 Posted September 1, 2010 Share Posted September 1, 2010 You really should do that in header.php and return only smarty variables to be used in the template.Also, use the PS style stuff.the Db class has already been created when header.php is called so you can run your sql like this: $result = Db::ExecuteS('sql query here'); Take a look at the PS code to see how it is done.I learned about doing this stuff when I wrote my own class to generate our dynamic reports and called a function in this class fromthe OrderHistory class after payment was validated. Link to comment Share on other sites More sharing options...
Recommended Posts