예제 #1
0
 public function reorder($where = '')
 {
     $k = $this->_tbl_key;
     $query = new TiendaQuery();
     $query->select($this->_tbl_key);
     $query->select('ordering');
     $query->from($this->_tbl);
     $query->order('ordering ASC');
     $query->order('country_name ASC');
     $this->_db->setQuery((string) $query);
     if (!($orders = $this->_db->loadObjectList())) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // correct all the ordering numbers
     for ($i = 0, $n = count($orders); $i < $n; $i++) {
         if ($orders[$i]->ordering >= 0) {
             if ($orders[$i]->ordering != $i + 1) {
                 $orders[$i]->ordering = $i + 1;
                 $query = new TiendaQuery();
                 $query->update($this->_tbl);
                 $query->set('ordering = ' . (int) $orders[$i]->ordering);
                 $query->where($k . ' = ' . $this->_db->Quote($orders[$i]->{$k}));
                 $this->_db->setQuery((string) $query);
                 $this->_db->query();
             }
         }
     }
     return true;
 }
예제 #2
0
 /**
  * First stores the record
  * Then checks if it should be the default
  *
  * @see tienda/admin/tables/TiendaTable#store($updateNulls)
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->is_default_shipping == '1' || $this->is_default_billing == '1') {
             // update the defaults
             $query = new TiendaQuery();
             $query->update("#__tienda_addresses");
             $query->where("`user_id` = '{$this->user_id}'");
             $query->where("`address_id` != '{$this->address_id}'");
             if ($this->is_default_shipping == '1') {
                 $query->set("`is_default_shipping` = '0'");
             }
             if ($this->is_default_billing == '1') {
                 $query->set("`is_default_billing` = '0'");
             }
             $this->_db->setQuery((string) $query);
             if (!$this->_db->query()) {
                 $this->setError($this->_db->getErrorMsg());
                 return false;
             }
         }
     }
     return $return;
 }
예제 #3
0
 public function clearSessionIds()
 {
     $query = new TiendaQuery();
     $query->update('#__tienda_wishlistitems');
     $query->set("session_id = ''");
     $query->where("user_id > 0");
     $db = $this->getDBO();
     $db->setQuery((string) $query);
     if (!$db->query()) {
         return false;
     }
     return true;
 }
예제 #4
0
파일: carts.php 프로젝트: annggeel/tienda
 /**
  *
  * @param unknown_type $user_id
  * @param unknown_type $session_id
  * @return unknown_type
  */
 function updateUserCartItemsSessionId($user_id, $session_id)
 {
     $db = JFactory::getDBO();
     Tienda::load('TiendaQuery', 'library.query');
     $query = new TiendaQuery();
     $query->update("#__tienda_carts");
     $query->set("`session_id` = '{$session_id}' ");
     $query->where("`user_id` = '{$user_id}'");
     $db->setQuery((string) $query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     return true;
 }