IBACK Posted February 4, 2015 Share Posted February 4, 2015 Hello, I added a tab to BACK-OFFICE with a associated PHP page (AdminMyPage.php). This is the source of the page : <?php include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminMyPage extends AdminTab { private $results; public function __construct() { parent::__construct(); // date of the day $today = getdate(); if ($today['mday'] < 10) $day = "0" .$today['mday']; else $day = $today['mday']; if ($today['mon'] < 10) $month = "0" .$today['mon']; else $month = $today['mon']; $dateJour = $day . "/" . $month . "/" . $today['year']; } public function displayForm() { $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $sql = "SELECT count(*) as nb FROM `" . _DB_PREFIX_ . "belvg_CA_customerattributes_customer` WHERE id_belvg_customerattributes = 1 and value = '" . $dateJour . "' "; $this->results = Db::getInstance()->ExecuteS($sql); if ($this->results) { foreach ($this->results as $row) echo $row['dt_rdv'].' :: '.$row['nb'].'<br />'; } else echo "no data !"; } } ?> When i execute this page (click on my tab / BACK_OFFICE), i have this message : BAD SQL QUERY The query is correct (tested with phpMyAdmin). Any ideas ? thanks you in advance Fabrice Link to comment Share on other sites More sharing options...
razaro Posted February 4, 2015 Share Posted February 4, 2015 Think it is a problem with $dateJour variable. It is undefined in displayForm () function. You could move date calulation in displayForm or make dateJaour class variable. Link to comment Share on other sites More sharing options...
IBACK Posted February 4, 2015 Author Share Posted February 4, 2015 Think it is a problem with $dateJour variable. It is undefined in displayForm () function. You could move date calulation in displayForm or make dateJaour class variable. I move date calculation in displayForm (of course) but i have always the same problem : BAD SQL QUERY ! Just a precision : i work with Prestashop 1.6 Link to comment Share on other sites More sharing options...
razaro Posted February 4, 2015 Share Posted February 4, 2015 Try to turn debug mode on in folder config, file defines.inc.php set if (!defined('_PS_MODE_DEV_')) define('_PS_MODE_DEV_', true); Maybe it will get some hint what is wrong. And if you get count maybe to try with this (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); Link to comment Share on other sites More sharing options...
IBACK Posted February 4, 2015 Author Share Posted February 4, 2015 This is the debug message : Fatal error: Uncaught Table 'mybase.ps_' doesn't exist SELECT SQL_CALC_FOUND_ROWS a.* FROM `ps_` a WHERE 1 ORDER BY a.`id_` ASC LIMIT 0,50 thrown in /home/xxxxxx/classes/db/Db.php on line 639 very strange ! The name of the table is supplied in my query ! ('ps_belvg_CA_customerattributes_customer') Link to comment Share on other sites More sharing options...
J. Danse Posted February 4, 2015 Share Posted February 4, 2015 It's the construction list. The tab constructor want to get some fields of one table. If no data, this is a bad sql query. Add, in your constructor this: $this->table = 'belvg_CA_customerattributes_customer'; Link to comment Share on other sites More sharing options...
IBACK Posted February 5, 2015 Author Share Posted February 5, 2015 ok thanks it's ok no message "BAD QUERY SQL" 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