×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Roman Ignatov
Added: Nov 22, 2016 4:55 PM
Modified: Nov 22, 2016 4:55 PM
Views: 14
Tags: magento
  1. <?php
  2.  
  3. // FROM MODEL
  4.  
  5. /** @var Varien_Db_Adapter_Interface $read */
  6. $read = $this->getResource()->getReadConnection();
  7. $cond = [
  8.     $read->quoteInto("`code` = ?", $code),
  9.     $read->quoteInto("`reseller_id` = ?", $resId),
  10. ];
  11.  
  12. $read->update('some_table_name', ['value1' => '1'], implode(" AND ", $cond) );
  13.  
  14.  
  15. // FROM RESOURCE MODEL
  16.  
  17. $conditions = array(
  18.             $this->_getWriteAdapter()->quoteInto("`status` = ?", $status),
  19.             $this->_getWriteAdapter()->quoteInto("(`updated_at` < ? OR `updated_at` IS NULL)", $dateLimit),
  20.             $this->_getWriteAdapter()->quoteInto("`created_at` < ?", $dateLimit),
  21. );
  22.  
  23. $this->_getWriteAdapter()->delete($this->getMainTable(), implode(" AND ", $conditions));