sergito Posted July 20, 2010 Share Posted July 20, 2010 Hi people, i have a "hello world" module installed in prestashop. It works. One of the php scripts prints a list introduced in the module configuration. This script has the following code: $sql = "select * from ejemplo order by id desc;"; $result = Db::getInstance() -> ExecuteS($sql); $smarty->assign('lista',$result);and it works, the TPL file shows the list. But now i want to assing a simple variable to smarty. I have the following code: $sql = "select * from ejemplo where id=1;"; $result = Db::getInstance() -> Execute($sql); $smarty->assign('variable',$result['frasebienvenida']);The difference between both are "Execute" function. This is for retrieving only one row, like are explaned into Db.php script of prestashop. But it doesn't work. Ive tried with several things like using getRow() function, passing directly $result to smarty and then accesing {$variable.frasebienvenida} but any of this works. the tpl file doesn's show anything. tipping the sql sentence from mysql console shows one row.can anybody help me? Link to comment Share on other sites More sharing options...
sergito Posted July 20, 2010 Author Share Posted July 20, 2010 aditional explanation. the following code make tpl to print 'pepe', but assigning $result['frasebienvenida'] doesn't show anything. 'frasebienvenida' exists in table ejemplo. $sql = "select * from ejemplo where id=1;"; $result = Db::getInstance() -> Execute($sql); if ($result != null) $smarty->assign('variable','pepe'); else $smarty->assign('variable','vacioo'); Link to comment Share on other sites More sharing options...
Burhan BVK Posted July 20, 2010 Share Posted July 20, 2010 "Execute()" does return any rows. "ExecuteS()" returns an array of rows, "getRow()" returns only the first row. Link to comment Share on other sites More sharing options...
sergito Posted July 21, 2010 Author Share Posted July 21, 2010 ok i thought that Execute() could be used because there was an abstract method Execute() into Db.phpthanks 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