prestashop_newuser Posted January 24, 2014 Share Posted January 24, 2014 (edited) Hi, I have the database like this CREATE TABLE IF NOT EXISTS `ps_pagenames` ( `page_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `page_name` varchar(120) NOT NULL, `page_type` varchar(120) NOT NULL, PRIMARY KEY (`page_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; INSERT INTO ``ps_pagenames` (`page_id`, `page_name`, `page_type`) VALUES (1, 'home_page', 'index'), (2, 'product_page', 'product'), (3, 'category_page', 'category'); Now I wanted to get the last inserted values from the database. So for that I made the query like this $pages_query = 'SELECT * FROM `'._DB_PREFIX_.'pagenames` ORDER BY `page_id` DESC LIMIT 0 , 1'; $query_result = Db::getInstance()->executeS($pages_query); Now when I tried to check the fetched values by using print_r($query_result); It showed me the same array two times like this Array ( [0] => Array ( [page_id] => 3 [page_name] => category_page [page_type] => category ) ) Array ( [0] => Array ( [page_id] => 3 [page_name] => category_page [page_type] => category ) ) Even I tried to use foreach loop. but still its showing the above array. So can someone kindly tell me how to fix this issue.I want only one array with the values. Any help will be really appreciable. Thanks Edited January 24, 2014 by vekia (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted January 24, 2014 Share Posted January 24, 2014 if you remove print_r($query_result); - second resul appears too, or it just disappears? Link to comment Share on other sites More sharing options...
prestashop_newuser Posted January 24, 2014 Author Share Posted January 24, 2014 if you remove print_r($query_result); - second resul appears too, or it just disappears? If I remove print_r($query_result) then it does not display anything. I had used print_r($query_result) for checking my return array but here it is coming two times. Link to comment Share on other sites More sharing options...
vekia Posted January 24, 2014 Share Posted January 24, 2014 ok i understand,so, it looks like there is some loop, maybe for? foreach?can you show code of your function, where you use it? Link to comment Share on other sites More sharing options...
prestashop_newuser Posted January 24, 2014 Author Share Posted January 24, 2014 (edited) ok i understand, so, it looks like there is some loop, maybe for? foreach? can you show code of your function, where you use it? Hi Vekia, I got the solution. Actually I had done a mistake by doing two display Hooks like this public function hookLeftColumn($params) { return $this->hookRightColumn($params); } public function hookRightColumn($params) { global $cookie, $smarty; $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $smarty->assign('defaultLanguage', $defaultLanguage); $this->_hookCommon($params); return $this->display(__FILE__, 'template.tpl'); } and inside hookRightColumn($params) I had made print_r($query_result), as you can see I have assigned two hooks to the template thats why print_r($query_result) showed the array two times. Thank you for your suggestion. Now you can make this issue as resolved Edited January 24, 2014 by prestashop_newuser (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted January 24, 2014 Share Posted January 24, 2014 thank you for clarification where the problem was i marked topic as solved exactly as you suggested with regards, Milos Link to comment Share on other sites More sharing options...
Recommended Posts