Skip to content

Commit

Permalink
改进autoinc判断
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Aug 5, 2024
1 parent 48fc26e commit f9fc4f1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/db/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ public function insert(BaseQuery $query, bool $getLastInsID = false)

if ($lastInsId) {
$pk = $query->getAutoInc();
if ($pk) {
if ($pk && is_string($pk)) {
$data[$pk] = $lastInsId;
}
}
Expand Down Expand Up @@ -1283,7 +1283,7 @@ public function value(BaseQuery $query, string $field, $default = null, bool $on
*
* @return mixed
*/
public function aggregate(BaseQuery $query, string $aggregate, string|Raw $field, bool $force = false)
public function aggregate(BaseQuery $query, string $aggregate, string | Raw $field, bool $force = false)
{
if (is_string($field) && 0 === stripos($field, 'DISTINCT ')) {
[$distinct, $field] = explode(' ', $field);
Expand Down Expand Up @@ -1766,12 +1766,8 @@ public function getLastInsID(BaseQuery $query, string $sequence = null)
protected function autoInsIDType(BaseQuery $query, string $insertId)
{
$pk = $query->getAutoInc();

if (is_array($pk)) {
return $insertId;
}

if ($pk) {
if ($pk && is_string($pk)) {
$type = $this->getFieldsBind($query->getTable())[$pk];

if (self::PARAM_INT == $type) {
Expand Down

0 comments on commit f9fc4f1

Please sign in to comment.