BenitoBenitez Posted December 21, 2013 Share Posted December 21, 2013 Hi, i am new user of prestashop, and i try learn some of php I need SELECT a order and show it, but something its wrong, here my code: .php if (!defined('_PS_VERSION_')) exit; class Estadisticas extends Module { private $_join = ''; private $_where = ''; public function __construct() { $this->name = 'estadisticas'; $this->tab = 'estadisticas'; $this->version = 1.0; $this->author = 'benito'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('estadisticas'); $this->description = $this->l('estadisticas'); } public function install() { return (parent::install() && $this->registerHook('AdminStatsModules')); } public function hookAdminStatsModules( $params ){ global $smarty; $sql="select * from ps_orders"; // creamos la sentencia sql $query=mysql_query($sql); // ejecutamos la consulta while($row=mysql_fetch_array($query)){ $datos=array($row['id_order']); } mysql_close(); $smarty->assign('datos' ,$datos); return $this->display(__FILE__, 'estadisticas.tpl'); } } And tpl <div id="module_testing_block_left" class="block"> <h4>Estadisticas</h4> <div class="block_content"> <table border="0" cellspacing="5" cellpadding="5"> {foreach key=key name=outer item=dato from=$datos} <tr class=""> {foreach key=key item=item from=$dato} <td align="left">{$item['id_order']}</td> {/foreach} </tr> {/foreach} </table> </div> </div> i need show id_order and my code not work 100% only show the h4 Thanks! Link to comment Share on other sites More sharing options...
El Patron Posted December 21, 2013 Share Posted December 21, 2013 this document on 'best practices' might help http://doc.prestashop.com/display/PS15/DB+class+best+practices Link to comment Share on other sites More sharing options...
tuk66 Posted December 23, 2013 Share Posted December 23, 2013 I would use Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `'._DB_PREFIX_.'orders`'); Link to comment Share on other sites More sharing options...
Recommended Posts