Пример #1
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param   array  $items  An array of primary key value to delete.
  *
  * @return  int  Returns count of success
  */
 public function delete($items)
 {
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $ids = '';
     $app = JFactory::getApplication();
     $ids = count($items) > 1 ? implode(',', $items) : $items[0];
     $path = JPATH_SITE . '/components/com_quick2cart/helpers/zoneHelper.php';
     if (!class_exists('zoneHelper')) {
         JLoader::register('zoneHelper', $path);
         JLoader::load('zoneHelper');
     }
     $zoneHelper = new zoneHelper();
     if (is_array($items)) {
         $successCount = 0;
         foreach ($items as $id) {
             // Check whether zone is allowed to delete or not.  If not the enqueue error message accordingly.
             $count_id = $zoneHelper->isAllowedToDelZone($id);
             if ($count_id === true) {
                 try {
                     $query = $db->getQuery(true)->delete('#__kart_zone')->where('id =' . $id);
                     $db->setQuery($query);
                     if (!$db->execute()) {
                         $this->setError($this->_db->getErrorMsg());
                         return 0;
                     }
                 } catch (RuntimeException $e) {
                     $this->setError($e->getMessage());
                     throw new Exception($this->_db->getErrorMsg());
                     return 0;
                 }
                 // For enqueue success msg along with error msg.
                 $successCount += 1;
             }
         }
         return $successCount;
     }
 }
Пример #2
0
 public function delete($pk = null)
 {
     $zoneHelper = new zoneHelper();
     if ($pk) {
         // Check whether zone is allowed to delete or not.  If not the enqueue error message accordingly.
         $count_id = $zoneHelper->isAllowedToDelZone($pk);
         if ($count_id === true) {
             $this->load($pk);
             $result = parent::delete($pk);
             if ($result) {
             }
             return $result;
         }
     }
 }