mardon Posted November 3, 2014 Share Posted November 3, 2014 Hi all, I am trying to write owm php script from importing data from xml file. I have function function updateCategory ($name, $level_depth, $lang) { echo 'UPDATE Kategorie '.$name."<br />"; $sql = 'UPDATE '._DB_PREFIX_.'category c, '._DB_PREFIX_.'category_lang cl SET date_upd = now() WHERE c.id_category = cl.id_category AND cl.name = "'.$name.'" AND cl.id_lang = '.$lang.' AND c.level_depth = '.$level_depth.';'; $flag = Db::getInstance()->execute($sql); if ( !$flag ) echo "Chyba pri Update category: ".$name."<br />"; } execute sql produce error, when I am using the sql command from phpmyadmin is ok, but in script produce error even when i see in database the date_upd is changed to now Link to comment Share on other sites More sharing options...
tuk66 Posted November 3, 2014 Share Posted November 3, 2014 How does look the $sql query? Link to comment Share on other sites More sharing options...
mardon Posted November 3, 2014 Author Share Posted November 3, 2014 for example: UPDATE ps_category c, ps_category_lang cl SET date_upd = now() WHERE c.id_category = cl.id_category AND cl.name = "Elektronická cigareta" AND cl.id_lang = 1 AND c.level_depth = 2; Link to comment Share on other sites More sharing options...
musicmaster Posted November 3, 2014 Share Posted November 3, 2014 What is the error message? Link to comment Share on other sites More sharing options...
mardon Posted November 4, 2014 Author Share Posted November 4, 2014 maybe is thata problem? Fatal error: Uncaught Cannot execute queries while other unbuffered queries are activUne. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.<br /><br /><pre>UPDATE ps_category c, ps_category_lang cl SET date_upd = now() WHERE c.id_category = cl.id_category AND cl.name = "Elektronická cigareta" AND cl.id_lang = 1 AND c.level_depth = 2;</pre> thrown in D:\web\ps16\classes\db\Db.php on line 635 Link to comment Share on other sites More sharing options...
mardon Posted November 4, 2014 Author Share Posted November 4, 2014 It seems I find the problem before I have this SQL $sql = 'SELECT c.id_category FROM '._DB_PREFIX_.'category_lang cl, '._DB_PREFIX_.'category c WHERE c.id_category = cl.id_category AND cl.name="'.$name.'" AND c.level_depth='.($level_depth).' AND cl.id_lang = '.$lang.';'; $res = mysql_query($sql); if (mysql_num_rows($res)>0) { echo 'Kategorie '.$name.' jiz existuje'."<br />"; return true; } else { echo 'Kategorie '.$name.' neni v systemu'."<br />"; return false; } when I changeid to $sql = 'SELECT c.id_category FROM '._DB_PREFIX_.'category_lang cl, '._DB_PREFIX_.'category c WHERE c.id_category = cl.id_category AND cl.name="'.$name.'" AND c.level_depth='.($level_depth).' AND cl.id_lang = '.$lang.';' Db::getInstance()->ExecuteS($sql); $num_rows = Db::getInstance()->NumRows(); if ($num_rows>0) { echo 'Kategorie '.$name.' jiz existuje'."<br />"; return true; } else { echo 'Kategorie '.$name.' neni v systemu'."<br />"; return false; } now is everything ok Link to comment Share on other sites More sharing options...
Recommended Posts