当前位置: 首页>>代码示例>>PHP>>正文


PHP JTable::delete方法代码示例

本文整理汇总了PHP中JTable::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::delete方法的具体用法?PHP JTable::delete怎么用?PHP JTable::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JTable的用法示例。


在下文中一共展示了JTable::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 public function delete($pk = null)
 {
     // Get form model
     $formModel = JModelLegacy::getInstance('form', 'IssnregistryModel');
     if ($pk != null) {
         // Get number of forms related to this publisher
         $formsCount = $formModel->getFormsCountByPublisherId($pk);
         // Check result
         if ($formsCount != 0) {
             // If there are forms, the publisher can't be deleted
             JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_PUBLISHER_DELETE_FAILED_FORMS_EXIST'), 'warning');
             // Return false as the item can't be deleted
             return false;
         }
         // Delete messages
         //$messageModel = JModelLegacy::getInstance('message', 'IssnregistryModel');
         //$messageModel->deleteByPublisherId($pk);
     }
     if (parent::delete($pk)) {
         // If this publisher was created based on a form, remove
         // publisher created attribute from the form
         if ($this->form_id != 0) {
             $formModel->removePublisherCreated($this->form_id);
         }
         // Get message model
         $messageModel = JModelLegacy::getInstance('message', 'IssnregistryModel');
         // Delete messages related to this publisher
         $messageModel->deleteByPublisherId($pk);
         // Return true
         return true;
     }
     return false;
 }
开发者ID:petkivim,项目名称:id-registry,代码行数:33,代码来源:publisher.php

示例2: delete

 /**
  * Deletes a group message.
  *
  * @param   integer  $pk  Primary key of the message type to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Delete messages
     $messageModel = JModelLegacy::getInstance('message', 'IsbnregistryModel');
     $messageModel->deleteByGroupMessageId($pk);
     return parent::delete($pk);
 }
开发者ID:petkivim,项目名称:id-registry,代码行数:15,代码来源:groupmessage.php

示例3: deleteBy

 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  * 			instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * */
 public function deleteBy($params = null)
 {
     if (!empty($params) && !is_array($params)) {
         return parent::delete($params);
     }
     // If no primary key is given, return false.
     if (empty($params)) {
         $e = new JException(JText::_('MIGUR_PARAMS_IS_ABSENT'));
         $this->setError($e);
         return false;
     }
     // Delete the row by primary key.
     $query = $this->_db->getQuery(true);
     $query->delete();
     $query->from($this->_tbl);
     $fields = array_keys($this->getFields());
     //print_r($fields);
     foreach ($params as $name => $val) {
         if (in_array($name, $fields)) {
             $query->where($name . ' = ' . $this->_db->quote($val));
         } else {
             $e = new JException(JText::_('MIGUR_THE_FIELD_NOT_IN_THE_TABLE'));
             $this->setError($e);
             return false;
         }
     }
     $this->_db->setQuery($query);
     // Check for a database error.
     if (!$this->_db->query()) {
         $e = new JException(JText::_('JLIB_DATABASE_ERROR_DELETE_FAILED', get_class($this), $this->_db->getErrorMsg()));
         $this->setError($e);
         return false;
     }
     return true;
 }
开发者ID:Rikisha,项目名称:proj,代码行数:43,代码来源:table.php

示例4: delete

 function delete($pk = null)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     // If no primary key is given, return false.
     if ($pk === null) {
         $e = new JException(JText::_('JLIB_DATABASE_ERROR_NULL_PRIMARY_KEY'));
         $this->setError($e);
         return false;
     }
     // Check if the category has products related
     $query = 'SELECT product_id FROM #__cp_products WHERE category_id = ' . $pk;
     $this->_db->setQuery($query);
     if (!$this->_db->execute()) {
         $this->db_error = true;
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($this->_db->getNumRows() > 0) {
         $e = new JException(JText::_('COM_CP_ERROR_DELETING_CATEGORIES'));
         $this->setError($e);
         return false;
     }
     // Delete associations
     return parent::delete($pk);
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:27,代码来源:cpcategory.php

示例5: delete

 /**
  * Deletes a Publication.
  *
  * @param   integer  $pk  Primary key of the publication to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Item can be deleted only if it doesn't have ISSN yet
     if (!empty($this->issn)) {
         // If identifier exists, raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_PUBLICATIONS_DELETE_FAILED'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // No identifiers found, delete the item
     if (parent::delete($pk)) {
         if ($this->form_id > 0) {
             // Load form model
             $formModel = JModelLegacy::getInstance('form', 'IssnregistryModel');
             // Get form
             $form = $formModel->getItem($this->form_id);
             // Decrease publication count by one
             if (!$formModel->decreasePublicationCount($form->id, $form->publication_count)) {
                 //JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_FORM_UPDATE_PUBLICATION_COUNT_FAILED'), 'warning');
             }
         }
         // Load publication archive model
         $publicationArchiveModel = JModelLegacy::getInstance('publicationarchive', 'IssnregistryModel');
         // Delete archive record
         $publicationArchiveModel->deleteByPublicationId($this->id);
         return true;
     }
     return false;
 }
开发者ID:petkivim,项目名称:id-registry,代码行数:37,代码来源:publication.php

示例6: delete

 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Delete all rooms belong to it
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/models', 'SolidresModel');
     $query->clear();
     $query->select('*')->from($this->_db->quoteName('#__sr_rooms'))->where('room_type_id = ' . $this->_db->quote($pk));
     $rooms = $this->_db->setQuery($query)->loadObjectList();
     $roomModel = JModelLegacy::getInstance('Room', 'SolidresModel');
     foreach ($rooms as $room) {
         $roomModel->delete($room->id);
     }
     // Delete all coupons relation
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_coupon_xref'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all extras relation
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_extra_xref'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all custom fields
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_fields'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all media
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_media_roomtype_xref'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all prices
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_prices'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete itself
     return parent::delete($pk);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:44,代码来源:roomtype.php

示例7: delete

 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param   mixed    $pk  An optional primary key value to delete.  If not set the
  *                        instance property value is used.
  *
  * @return  boolean  True on success.
  * @since   0.3.0
  */
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     $query = $this->_db->getQuery(true);
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/models', 'UsersModel');
     // Take care of Customer records
     $query->select('COUNT(id)')->from($this->_db->quoteName('#__sr_customers'))->where('customer_group_id = ' . $pk);
     $this->_db->setQuery($query);
     $result = (int) $this->_db->loadResult();
     if ($result > 0) {
         $e = new JException(JText::sprintf('SR_ERROR_CUSTOMER_GROUP_CONTAINS_CUSTOMER', $this->name));
         $this->setError($e);
         return false;
     }
     // Delete all prices
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_prices'))->where('customer_group_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Take care of Coupon
     $couponsModel = JModelLegacy::getInstance('Coupons', 'SolidresModel', array('ignore_request' => true));
     $couponModel = JModelLegacy::getInstance('Coupon', 'SolidresModel', array('ignore_request' => true));
     $couponsModel->setState('filter.customer_group_id', $pk);
     $coupons = $couponsModel->getItems();
     foreach ($coupons as $coupon) {
         $couponModel->delete($coupon->id);
     }
     // Delete it
     return parent::delete($pk);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:39,代码来源:customergroup.php

示例8: delete

 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Delete from Media roomtype xref first
     // We delete manually instead of using ON DELETE CASCADE of Innodb table type
     // If has any relationship with RoomType, delete them all
     $query->clear();
     $query->delete()->from($this->_db->quoteName('#__sr_media_roomtype_xref'))->where('media_id = ' . $pk);
     $this->_db->setQuery($query);
     if (!$this->_db->execute()) {
         JError::raiseWarning(100, JText::sprintf('SolidresControllerMedia::delete ' . $this->_db->quoteName('#__sr_media_roomtype_xref') . ' failed', get_class($this), $this->_db->getErrorMsg()));
         return false;
     }
     // Delete the relationship with ReservationAsset first
     // We delete manually instead of using ON DELETE CASCADE of Innodb table type
     // If has any relationship with ReservationAsset, delete them all
     $query->clear();
     $query->delete()->from($this->_db->quoteName('#__sr_media_reservation_assets_xref'))->where('media_id = ' . $pk);
     $this->_db->setQuery($query);
     if (!$this->_db->execute()) {
         JError::raiseWarning(100, JText::sprintf('SolidresControllerMedia::delete from ' . $this->_db->quoteName('#__sr_media_reservation_assets_xref') . ' failed', get_class($this), $this->_db->getErrorMsg()));
         return false;
     }
     return parent::delete($pk);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:34,代码来源:media.php

示例9: delete

 /**
  * Overrides Joomla's JTable delete method so that we can update the ordering
  * upon deleting
  * 
  * @return boolean true on success
  **/
 public function delete()
 {
     $db =& $this->getDBO();
     $query = "UPDATE " . $db->nameQuote('#__community_fields') . ' ' . 'SET ' . $db->nameQuote('ordering') . ' = (' . $db->nameQuote('ordering') . ' -1 ) ' . 'WHERE ' . $db->nameQuote('ordering') . '>' . $this->ordering;
     $db->setQuery($query);
     $db->query();
     return parent::delete();
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:14,代码来源:profiles.php

示例10: delete

 public function delete($pk = null)
 {
     if ($this->id) {
         // Delete Template
         // Delete Views
     }
     return parent::delete();
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:8,代码来源:template.php

示例11: delete

 public function delete($oid = null)
 {
     $result = parent::delete($oid);
     if ($result) {
         $this->_updateGroupStats();
     }
     return $result;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:8,代码来源:discussion.php

示例12: testDeleteKeysProvided

	/**
	 * Test for delete method with keys provided.
	 *
	 * @covers JTable::delete
	 *
	 * @return  void
	 *
	 * @since   12.3
	 */
	public function testDeleteKeysProvided()
	{
		$this->assertEquals(2, $this->getConnection()->getRowCount('jos_dbtest_composite'), "Pre-Condition");

		$this->object->delete(array('id1' => 25, 'id2' => 50));

		$this->assertEquals(1, $this->getConnection()->getRowCount('jos_dbtest_composite'), "Delete failed.");
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:17,代码来源:JTableTest.php

示例13: delete

 /**
  * Overloads the delete method to ensure we're not deleting the default profile
  *
  * @param int $id Optional; the record id
  */
 function delete($id = null)
 {
     if ($id == 1 || is_null($id) && $this->id == 1) {
         $this->setError(JText::_('TABLE_PROFILE_CANNOTDELETEDEFAULT'));
         return false;
     } else {
         return parent::delete($id);
     }
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:14,代码来源:profile.php

示例14: delete

 public function delete($pk = null)
 {
     //Delete criterias first.
     $criterias = $this->getCriterias();
     foreach ($criterias as $criteria) {
         $criteria->delete();
     }
     return parent::delete();
 }
开发者ID:Jougito,项目名称:DynWeb,代码行数:9,代码来源:memberlist.php

示例15: delete

 /**
  * Override the delete function as we need to delete the fields also
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		5.9.5
  */
 public function delete($pk = null)
 {
     if (parent::delete($pk)) {
         $query = $this->_db->getQuery(true)->delete($this->_db->qn('#__csvi_mapheaders'))->where($this->_db->qn('map_id') . '=' . $this->_db->q($pk));
         $this->_db->setQuery($query);
         $this->_db->execute();
         return true;
     }
 }
开发者ID:alesconti,项目名称:FF_2015,代码行数:21,代码来源:map.php


注:本文中的JTable::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。