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


PHP Record::deleteWhere方法代码示例

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


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

示例1: setRolesFor

 public static function setRolesFor($user_id, $roles)
 {
     Record::deleteWhere('UserRole', 'user_id = :user_id', array(':user_id' => (int) $user_id));
     foreach ($roles as $role => $role_id) {
         Record::insert('UserRole', array('user_id' => (int) $user_id, 'role_id' => (int) $role_id));
     }
 }
开发者ID:ariksavage,项目名称:superior-optical-eyewear,代码行数:7,代码来源:UserRole.php

示例2: deletePageTagRelationship

 public static function deletePageTagRelationship($page_id, $tag_id)
 {
     // get the id of the tag
     $tag = Record::findOneFrom('Tag', 'id=?', array($tag_id));
     Record::deleteWhere('PageTag', 'page_id=? AND tag_id=?', array($page_id, $tag->id));
     $tag->count--;
     $tag->save();
     return true;
 }
开发者ID:silentworks,项目名称:tagger,代码行数:9,代码来源:TaggerTag.php

示例3: save_by_page

 /**
  * 
  * @param integer|Model_Page_Front $page_id
  * @param array $tags
  */
 public static function save_by_page($page_id, $tags)
 {
     if (is_string($tags)) {
         $tags = explode(Model_Tag::SEPARATOR, $tags);
     }
     $tags = array_unique(array_map('trim', $tags));
     $current_tags = Model_Page_Tag::find_by_page($page_id);
     if ($page_id instanceof Model_Page_Front) {
         $page_id = $page_id->id();
     }
     // no tag before! no tag now! ... nothing to do!
     if (empty($tags) and empty($current_tags)) {
         return NULL;
     }
     // delete all tags
     if (empty($tags)) {
         // update count (-1) of those tags
         foreach ($current_tags as $tag) {
             DB::update(Model_Tag::tableName())->set(array('count' => DB::expr('count - 1')))->where('name', '=', $tag)->execute();
         }
         Record::deleteWhere(self::tableName(), array('where' => array(array('page_id', '=', (int) $page_id))));
         Cache::instance()->delete_tag('page_tags');
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (empty($tag_name)) {
                 continue;
             }
             $tag = Record::findOneFrom('Model_Tag', array('where' => array(array('name', '=', $tag_name))));
             // try to get it from tag list, if not we add it to the list
             if (!$tag instanceof Model_Tag) {
                 $tag = new Model_Tag(array('name' => trim($tag_name)));
             }
             $tag->count++;
             $tag->save();
             // create the relation between the page and the tag
             $page_tag = new Model_Page_Tag(array('page_id' => (int) $page_id, 'tag_id' => $tag->id));
             $page_tag->save();
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Record::findOneFrom('Model_Tag', array('where' => array(array('name', '=', $tag_name))));
             Record::deleteWhere(self::tableName(), array('where' => array(array('page_id', '=', (int) $page_id), array('tag_id', '=', $tag->id))));
             $tag->count--;
             $tag->save();
         }
         Cache::instance()->delete_tag('page_tags');
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:57,代码来源:tag.php

示例4: saveTags

 public function saveTags($tags)
 {
     if (is_string($tags)) {
         $tags = explode(',', $tags);
     }
     $tags = array_map('trim', $tags);
     $current_tags = $this->getTags();
     // no tag before! no tag now! ... nothing to do!
     if (count($tags) == 0 && count($current_tags) == 0) {
         return;
     }
     // delete all tags
     if (count($tags) == 0) {
         $tablename = self::tableNameFromClassName('Tag');
         // update count (-1) of those tags
         foreach ($current_tags as $tag) {
             self::$__CONN__->exec("UPDATE {$tablename} SET count = count - 1 WHERE name = '{$tag}'");
         }
         return Record::deleteWhere('PageTag', 'page_id=?', array($this->id));
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (!empty($tag_name)) {
                 // try to get it from tag list, if not we add it to the list
                 if (!($tag = Record::findOneFrom('Tag', 'name=?', array($tag_name)))) {
                     $tag = new Tag(array('name' => trim($tag_name)));
                 }
                 $tag->count++;
                 $tag->save();
                 // create the relation between the page and the tag
                 $tag = new PageTag(array('page_id' => $this->id, 'tag_id' => $tag->id));
                 $tag->save();
             }
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Record::findOneFrom('Tag', 'name=?', array($tag_name));
             Record::deleteWhere('PageTag', 'page_id=? AND tag_id=?', array($this->id, $tag->id));
             $tag->count--;
             $tag->save();
         }
     }
 }
开发者ID:chaobj001,项目名称:tt,代码行数:46,代码来源:Page.php

示例5: clear404s

	function clear404s() {
	
		self::__checkPermission('redirector_delete');
		
		if ( ! Record::deleteWhere('Redirector404s','1') )
			Flash::set('error', __('There was a problem clearing the 404 errors!'));
			
		else
			Flash::set('success', __('404 Errors have been cleared!'));
		
		redirect(get_url('plugin/redirector/'));
	
	}
开发者ID:realslacker,项目名称:Redirector-Plugin,代码行数:13,代码来源:RedirectorController.php

示例6: saveTags

 public function saveTags($tags)
 {
     if (is_string($tags)) {
         $tags = explode(',', $tags);
     }
     $tags = array_map('trim', $tags);
     $tags = array_filter($tags);
     $current_tags = array();
     foreach ($this->tags() as $tag) {
         $current_tags[] = $tag->name();
     }
     // no tag before! no tag now! ... nothing to do!
     if (count($tags) == 0 && count($current_tags) == 0) {
         return;
     }
     // delete all tags
     if (count($tags) == 0) {
         return Record::deleteWhere('PageTag', 'page_id=?', array($this->id));
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (!empty($tag_name)) {
                 // try to get it from tag list, if not we add it to the list
                 if (!($tag = Tag::findByName($tag_name))) {
                     $tag = new Tag(array('name' => trim($tag_name)));
                 }
                 $tag->save();
                 // create the relation between the page and the tag
                 $tag = new PageTag(array('page_id' => $this->id, 'tag_id' => $tag->id));
                 $tag->save();
             }
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Tag::findByName($tag_name);
             Record::deleteWhere('PageTag', 'page_id=? AND tag_id=?', array($this->id, $tag->id));
             $tag->save();
         }
     }
 }
开发者ID:albertobraschi,项目名称:toad,代码行数:43,代码来源:Page.php

示例7: __storetags

	private function __storetags($tags,$download_id=null) {
	
		//	if download_id is provided clear out old tags
		if (!is_null($download_id)) Record::deleteWhere('DownloadTagConnection','download_id='.Record::escape((int)$download_id));
		
		//	check to make sure there are some tags
		if (empty($tags)) return true;
		
		//	take either an array or comma separated list of tags
		if (!is_array($tags)) $tags = explode(',',$tags);
		$tags = preg_replace('/[^a-z0-9 _,-]/','',$tags);
		
		//	find or create tag and connect to download
		foreach ($tags as $tagname) {
			$tagname = trim(strtolower($tagname));
			//	check for minimum tag length; must be at least three characters
			if (strlen($tagname) >= 3) {
				if (!$tag = DownloadTag::findByName($tagname)) {
					$tag = new DownloadTag(array('name'=>$tagname));
					$tag->save();
				}
				
				if (!is_null($download_id)) {
					$connection = new DownloadTagConnection(array(
						'download_id'=>(int)$download_id,
						'tag_id'=>$tag->id
					));
					$connection->save();
				}
			}
		}
		
		return true;
	}//*/
开发者ID:realslacker,项目名称:Downloads-Plugin,代码行数:34,代码来源:DownloadsController.php

示例8: product_delete

 public function product_delete($id)
 {
     if ($product = Record::findByIdFrom('Product', $id)) {
         $product_title = $product->title;
         //delete page for product
         if ($page = Record::findByIdFrom('Page', $product->page_id)) {
             $page->delete();
         }
         //delete variants
         Record::deleteWhere('ecommerce_product_variant', 'product_id=?', array($id));
         //delete images
         Record::deleteWhere('ecommerce_product_image', 'product_id=?', array($id));
         //delete files
         Record::deleteWhere('ecommerce_product_file', 'product_id=?', array($id));
         //delete videos
         Record::deleteWhere('ecommerce_product_video', 'product_id=?', array($id));
         if ($product->delete()) {
             //add log entry
             $this->_insert_log('Product \'' . $product_title . '\' was deleted.');
             Flash::set('success', __('Product has been deleted!'));
         } else {
             Flash::set('error', __('Product has not been deleted!'));
         }
     } else {
         Flash::set('error', __('Product not found!'));
     }
     redirect(get_url('plugin/ecommerce/product'));
 }
开发者ID:shuhrat,项目名称:frog_ecommerce,代码行数:28,代码来源:EcommerceController.php


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