Database Query prestashop 1.7

How to get the only one value from the db

- getValue

     
  return  Db::getInstance()->getValue('
            SELECT cart_id FROM `'._DB_PREFIX_.'ebanx` where  status = 0 ');

-executeS . Fetch data




$allcart =  Db::getInstance()->executeS($sql);

-Update

$sql = "update "._DB_PREFIX_."xyztable set deleted='1' where 1=1 ";
if (!Db::getInstance()->execute($sql))

-Insert

$language = array(

          , 'name'           => 'Awaiting  payment'
        
        ,
        );

        if (!Db::getInstance()->insert('order_state_lang', $language))
        {
            return false;
        }

DELETE

$sql = 'DELETE FROM `'._DB_PREFIX_.'competitor_url`  WHERE id_product ='.(int)$id_product;
if (!Db::getInstance()->execute($sql))
  die('error');

INSERT WITH FOREACH
$values = array();
foreach ($compititorList as $Key => $Value) {

  if(!empty($Value))
  {
      $values[] = array(
           'id_product' => (int)$id_product,
           'url' => $Value
       ); 
  } //if
    } //each

$res = Db::getInstance()->insert('competitor_url', $values);

Comments

Popular Posts