mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
数据库配置参数增加resultset_type 用于设置数据集的返回类型
This commit is contained in:
@@ -96,6 +96,8 @@ abstract class Connection
|
||||
'slave_no' => '',
|
||||
// 是否严格检查字段是否存在
|
||||
'fields_strict' => true,
|
||||
// 数据集返回类型
|
||||
'resultset_type' => Db::RESULTSET_ARRAY,
|
||||
];
|
||||
|
||||
// PDO连接参数
|
||||
@@ -233,7 +235,10 @@ abstract class Connection
|
||||
}
|
||||
// 记录当前字段属性大小写设置
|
||||
$this->attrCase = $params[PDO::ATTR_CASE];
|
||||
|
||||
// 记录数据集返回类型
|
||||
if (isset($config['resultset_type'])) {
|
||||
$this->resultSetType = $config['resultset_type'];
|
||||
}
|
||||
try {
|
||||
if (empty($config['dsn'])) {
|
||||
$config['dsn'] = $this->parseDsn($config);
|
||||
@@ -453,16 +458,16 @@ abstract class Connection
|
||||
{
|
||||
$result = $this->PDOStatement->fetchAll($this->fetchType);
|
||||
$this->numRows = count($result);
|
||||
// 返回指定对象类
|
||||
if (!empty($class)) {
|
||||
return new $class($result);
|
||||
}
|
||||
switch ($this->resultSetType) {
|
||||
case Db::RESULTSET_COLLECTION:
|
||||
// 返回数据集Collection对象
|
||||
$result = new Collection($result);
|
||||
break;
|
||||
case Db::RESULTSET_CLASS:
|
||||
// 返回指定对象类
|
||||
if (!empty($class)) {
|
||||
$result = new $class($result);
|
||||
}
|
||||
break;
|
||||
case Db::RESULTSET_ARRAY:
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user