當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DboSource::delete方法代碼示例

本文整理匯總了PHP中DboSource::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::delete方法的具體用法?PHP DboSource::delete怎麽用?PHP DboSource::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DboSource的用法示例。


在下文中一共展示了DboSource::delete方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testDeleteStatements

/**
 * Test deletes with a mock.
 *
 * @return void
 */
	public function testDeleteStatements() {
		$this->loadFixtures('Article', 'User');
		$test = ConnectionManager::getDatasource('test');
		$db = $test->config['database'];

		$this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config));

		$this->Dbo->expects($this->at(0))->method('execute')
			->with("DELETE  FROM `$db`.`articles`  WHERE 1 = 1");

		$this->Dbo->expects($this->at(1))->method('execute')
			->with("DELETE `Article` FROM `$db`.`articles` AS `Article` LEFT JOIN `$db`.`users` AS `User` " .
				"ON (`Article`.`user_id` = `User`.`id`)" .
				"  WHERE 1 = 1");

		$this->Dbo->expects($this->at(2))->method('execute')
			->with("DELETE `Article` FROM `$db`.`articles` AS `Article` LEFT JOIN `$db`.`users` AS `User` " .
				"ON (`Article`.`user_id` = `User`.`id`)" .
				"  WHERE 2=2");
		$Article = new Article();

		$this->Dbo->delete($Article);
		$this->Dbo->delete($Article, true);
		$this->Dbo->delete($Article, '2=2');
	}
開發者ID:hungnt88,項目名稱:5stars-1,代碼行數:30,代碼來源:MysqlTest.php

示例2: testDeleteNoComplexCondition

 /**
  * Test deletes without complex conditions.
  *
  * @return void
  */
 public function testDeleteNoComplexCondition()
 {
     $this->loadFixtures('Article', 'User');
     $test = ConnectionManager::getDatasource('test');
     $db = $test->config['database'];
     $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config));
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE `Article` FROM `{$db}`.`articles` AS `Article`   WHERE `id` = 1");
     $this->Dbo->expects($this->at(1))->method('execute')->with("DELETE `Article` FROM `{$db}`.`articles` AS `Article`   WHERE NOT (`id` = 1)");
     $Article = new Article();
     $conditions = array('id' => 1);
     $this->Dbo->delete($Article, $conditions);
     $conditions = array('NOT' => array('id' => 1));
     $this->Dbo->delete($Article, $conditions);
 }
開發者ID:hodrigohamalho,項目名稱:cakephp-ex,代碼行數:19,代碼來源:MysqlTest.php

示例3: testDeleteStatements

 /**
  * Test deletes with a mock.
  *
  * @return void
  */
 public function testDeleteStatements()
 {
     $this->loadFixtures('Boat', 'User');
     $test = ConnectionManager::getDatasource('test');
     $db = $test->config['database'];
     $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config));
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE  FROM `{$db}`.`boats`  WHERE 1 = 1");
     $this->Dbo->expects($this->at(1))->method('execute')->with("DELETE `Boat` FROM `{$db}`.`boats` AS `Boat` LEFT JOIN `{$db}`.`users` AS `User` " . "ON (`Boat`.`user_id` = `User`.`id`)" . "  WHERE 1 = 1");
     $this->Dbo->expects($this->at(2))->method('execute')->with("DELETE `Boat` FROM `{$db}`.`boats` AS `Boat` LEFT JOIN `{$db}`.`users` AS `User` " . "ON (`Boat`.`user_id` = `User`.`id`)" . "  WHERE 2=2");
     $Boat = new Boat();
     $this->Dbo->delete($Boat);
     $this->Dbo->delete($Boat, true);
     $this->Dbo->delete($Boat, '2=2');
 }
開發者ID:saikais,項目名稱:cruise,代碼行數:19,代碼來源:MysqlTest.php

示例4: delete

 /**
 	 408:  * Generates and executes an SQL DELETE statement for given id/conditions on given model.
 	 409:  *
 	 410:  * @param Model $model
 	 411:  * @param mixed $conditions
 	 412:  * @return boolean Success
 	 413:  */
 public function delete(Model $model, $conditions = null)
 {
     if (!$this->_useAlias) {
         return parent::delete($model, $conditions);
     }
     $alias = $this->name($model->alias);
     $table = $this->fullTableName($model);
     $joins = implode(' ', $this->_getJoins($model));
     if (empty($conditions)) {
         $alias = $joins = false;
     }
     $complexConditions = false;
     foreach ((array) $conditions as $key => $value) {
         if (strpos($key, $model->alias) === false) {
             $complexConditions = true;
             break;
         }
     }
     if (!$complexConditions) {
         $joins = false;
     }
     $conditions = $this->conditions($this->defaultConditions($model, $conditions, $alias), true, true, $model);
     if ($conditions === false) {
         return false;
     }
     if ($this->execute($this->renderStatement('delete', compact('alias', 'table', 'joins', 'conditions'))) === false) {
         $model->onError();
         return false;
     }
     return true;
 }
開發者ID:duyhn,項目名稱:learnlaw,代碼行數:38,代碼來源:Mysql.php

示例5: delete

 /**
  * Generates and executes an SQL DELETE statement for given id/conditions on given model.
  *
  * @param Model $model
  * @param mixed $conditions
  * @return boolean Success
  */
 function delete(&$model, $conditions = null)
 {
     if (!$this->_useAlias) {
         return parent::delete($model, $conditions);
     }
     $alias = $this->name($model->alias);
     $table = $this->fullTableName($model);
     $joins = implode(' ', $this->_getJoins($model));
     if (empty($conditions)) {
         $alias = $joins = false;
     }
     $conditions = $this->conditions($this->defaultConditions($model, $conditions, $alias), true, true, $model);
     if ($conditions === false) {
         return false;
     }
     if ($this->execute($this->renderStatement('delete', compact('alias', 'table', 'joins', 'conditions'))) === false) {
         $model->onError();
         return false;
     }
     return true;
 }
開發者ID:afzet,項目名稱:connectivo-crm,代碼行數:28,代碼來源:dbo_mysql.php


注:本文中的DboSource::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。