注释改进

This commit is contained in:
thinkphp
2016-05-18 12:30:55 +08:00
parent 5dc8cd481e
commit a00c4c51fe
4 changed files with 47 additions and 34 deletions

View File

@@ -595,22 +595,23 @@ abstract class Connection
* 批处理执行SQL语句
* 批处理的指令都认为是execute操作
* @access public
* @param array $sql SQL批处理指令
* @param array $sqlArray SQL批处理指令
* @return boolean
*/
public function batchQuery($sql = [])
public function batchQuery($sqlArray = [])
{
if (!is_array($sql)) {
if (!is_array($sqlArray)) {
return false;
}
// 自动启动事务支持
$this->startTrans(NOW_TIME);
$label = microtime(true);
$this->startTrans($label);
try {
foreach ($sql as $_sql) {
$result = $this->execute($_sql);
foreach ($sqlArray as $sql) {
$result = $this->execute($sql);
}
// 提交事务
$this->commit(NOW_TIME);
$this->commit($label);
} catch (\PDOException $e) {
$this->rollback();
return false;
@@ -717,9 +718,10 @@ abstract class Connection
}
/**
* 数据库调试 记录当前SQL
* 数据库调试 记录当前SQL及分析性能
* @access protected
* @param boolean $start 调试开始标记 true 开始 false 结束
* @return void
*/
protected function debug($start)
{
@@ -782,7 +784,7 @@ abstract class Connection
/**
* 初始化数据库连接
* @access protected
* @param boolean $master 主服务器
* @param boolean $master 是否主服务器
* @return void
*/
protected function initConnect($master = true)

View File

@@ -44,6 +44,7 @@ class Query
* 架构函数
* @access public
* @param \think\db\Connection|string $connection 数据库对象实例
* @param string $model 模型名
* @throws Exception
*/
public function __construct($connection = '', $model = '')
@@ -786,7 +787,19 @@ class Query
}
/**
* 指定默认数据表
* 指定默认数据表名(不含前缀)
* @access public
* @param string $name
* @return $this
*/
public function name($name)
{
$this->name = $name;
return $this;
}
/**
* 指定默认数据表名(含前缀)
* @access public
* @param string $table 表名
* @return $this
@@ -1046,23 +1059,11 @@ class Query
return $this;
}
/**
* 设置当前name
* @access public
* @param string $name
* @return $this
*/
public function name($name)
{
$this->name = $name;
return $this;
}
/**
* 获取数据表信息
* @access public
* @param string $fetch 获取信息类型 包括 fields type bind pk
* @param string $tableName 数据表名 留空自动获取
* @param string $fetch 获取信息类型 包括 fields type bind pk
* @return mixed
*/
public function getTableInfo($tableName = '', $fetch = '')
@@ -1113,7 +1114,7 @@ class Query
* 获取当前模型对象的主键
* @access public
* @param string $table 数据表名
* @return mixed
* @return string|array
*/
public function getPk($table = '')
{
@@ -1138,6 +1139,12 @@ class Query
return $this;
}
/**
* 检测参数是否已经绑定
* @access public
* @param string $key 参数名
* @return bool
*/
public function isBind($key)
{
return isset($this->bind[$key]);
@@ -1155,6 +1162,12 @@ class Query
return $this;
}
/**
* 获取当前的查询参数
* @access public
* @param string $name 参数名
* @return mixed
*/
public function getOptions($name = '')
{
return isset($this->options[$name]) ? $this->options[$name] : $this->options;
@@ -1164,7 +1177,7 @@ class Query
* 设置关联查询JOIN预查询
* @access public
* @param string|array $with 关联方法名称
* @return Db
* @return $this
*/
public function with($with)
{
@@ -1225,7 +1238,7 @@ class Query
* 设置当前字段添加的表别名
* @access public
* @param string $via
* @return Db
* @return $this
*/
public function via($via = '')
{
@@ -1237,7 +1250,7 @@ class Query
* 设置关联查询
* @access public
* @param string $relation 关联名称
* @return Db
* @return $this
*/
public function relation($relation)
{