Skip to content

Commit

Permalink
getAutoInc 判断是否string
Browse files Browse the repository at this point in the history
  • Loading branch information
hbh112233abc committed Dec 31, 2024
1 parent 17f491e commit 02957e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/connector/OpenGauss.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,11 @@ public function insert(BaseQuery $query, bool $getLastInsID = false)
// 执行操作
$result = '' == $sql ? [0] : $this->pdoInsertExecute($query, $sql);
if ($result[0]) {
$sequence = $options['sequence'] ?? null;
$lastInsId = $result[1];
$data = $options['data'];
if ($lastInsId) {
$pk = $query->getAutoInc();
if ($pk) {
if (is_string($pk) and $pk) {
$data[$pk] = $lastInsId;
}
}
Expand Down
17 changes: 17 additions & 0 deletions tests/t.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use think\facade\Db;
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/bingher/think-test/src/init.php';

$db = Db::connect('gbase_gauss');
$data = array(
'key' => md5(time()),
'code' => '35b91e042650d08c619d0446fc6629c5',
'captcha' => '{"text":[{"size":20,"icon":true,"name":"banana","text":"<香蕉>","width":40,"height":32,"x":191,"y":45},{"size":15,"icon":false,"name":"banana","text":"赶","width":20,"height":19,"x":315,"y":161}],"width":350,"height":200}',
'create_time' => 1735616906,
'expire_time' => 1735617506,
);
$res = $db->table('ba_captcha')->insertGetId($data);
dump($res);
assert($data['key'] == $res);

0 comments on commit 02957e9

Please sign in to comment.