-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove useless comments and translate comments
- Loading branch information
1 parent
9ed9341
commit 01690a8
Showing
10 changed files
with
156 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,34 +11,27 @@ | |
use Swoft\Helper\JsonHelper; | ||
|
||
/** | ||
* Mysql查询器 | ||
* | ||
* @uses QueryBuilder | ||
* @version 2017年09月01日 | ||
* @author stelin <[email protected]> | ||
* @copyright Copyright 2010-2016 swoft software | ||
* @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt} | ||
* Mysql query builder | ||
*/ | ||
class QueryBuilder extends \Swoft\Db\QueryBuilder | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $profilePrefix = "mysql"; | ||
private $profilePrefix = 'mysql'; | ||
|
||
/** | ||
* @return ResultInterface | ||
*/ | ||
public function execute() | ||
{ | ||
if(App::isCoContext()){ | ||
if (App::isCoContext()) { | ||
return $this->getCorResult(); | ||
} | ||
return $this->getSyncResult(); | ||
} | ||
|
||
/** | ||
* | ||
* @return DbDataResult | ||
*/ | ||
private function getSyncResult() | ||
|
@@ -52,15 +45,15 @@ private function getSyncResult() | |
$result = $this->connect->execute($this->parameters); | ||
|
||
App::profileEnd($profileKey); | ||
App::debug(sprintf("sql execute sqlId=%s, result=%s, sql=%s", $sqlId, JsonHelper::encode($result, JSON_UNESCAPED_UNICODE), $sql)); | ||
App::debug(sprintf('sql execute sqlId=%s, result=%s, sql=%s', $sqlId, JsonHelper::encode($result, JSON_UNESCAPED_UNICODE), $sql)); | ||
|
||
$result = $this->transferResult($result); | ||
|
||
if (is_array($result) && !empty($className)) { | ||
if (is_array($result) && ! empty($className)) { | ||
$result = EntityHelper::resultToEntity($result, $className); | ||
} | ||
|
||
if (!DbHelper::isContextTransaction($this->poolId)) { | ||
if (! DbHelper::isContextTransaction($this->poolId)) { | ||
$this->pool->release($this->connect); | ||
} | ||
|
||
|
@@ -81,28 +74,27 @@ private function getCorResult() | |
$this->connect->prepare($sql); | ||
$result = $this->connect->execute($this->parameters); | ||
|
||
App::debug(sprintf("sql execute sqlId=%s, sql=%s", $sqlId, $sql)); | ||
App::debug(sprintf('sql execute sqlId=%s, sql=%s', $sqlId, $sql)); | ||
$isUpdateOrDelete = $this->isDelete() || $this->isUpdate(); | ||
$isFindOne = $this->isSelect() && isset($this->limit['limit']) && $this->limit['limit'] == 1; | ||
$corResult = new DbCoResult($this->connect, $profileKey, $this->pool); | ||
$isFindOne = $this->isSelect() && isset($this->limit['limit']) && $this->limit['limit'] === 1; | ||
$corResult = new DbCoResult($this->connect, $profileKey, $this->pool); | ||
|
||
// 结果转换参数 | ||
$corResult->setPoolId($this->poolId); | ||
$corResult->setIsInsert($this->isInsert()); | ||
$corResult->setIsUpdateOrDelete($isUpdateOrDelete); | ||
$corResult->setIsFindOne($isFindOne); | ||
$corResult->setInsert($this->isInsert()); | ||
$corResult->setUpdateOrDelete($isUpdateOrDelete); | ||
$corResult->setFindOne($isFindOne); | ||
|
||
return $corResult; | ||
} | ||
|
||
/** | ||
* @param string $sql | ||
* | ||
* @return array | ||
*/ | ||
private function getSqlIdAndProfileKey(string $sql) | ||
{ | ||
$sqlId = md5($sql); | ||
$sqlId = md5($sql); | ||
$profileKey = sprintf('%s.%s', $sqlId, $this->profilePrefix); | ||
|
||
return [$sqlId, $profileKey]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.