@@ -686,7 +686,8 @@ public function getCursor(BaseQuery $query, string $sql, $model = null, $conditi
686
686
*/
687
687
public function query (string $ sql , array $ bind = [], bool $ master = false ): array
688
688
{
689
- return $ this ->pdoQuery ($ this ->newQuery ()->bind ($ bind ), $ sql , $ master );
689
+ $ this ->getPDOStatement ($ sql , $ bind , $ master );
690
+ return $ this ->getResult ();
690
691
}
691
692
692
693
/**
@@ -701,7 +702,25 @@ public function query(string $sql, array $bind = [], bool $master = false): arra
701
702
*/
702
703
public function execute (string $ sql , array $ bind = []): int
703
704
{
704
- return $ this ->pdoExecute ($ this ->newQuery ()->bind ($ bind ), $ sql , true );
705
+ $ this ->getPDOStatement ($ sql , $ bind , true );
706
+ return $ this ->PDOStatement ->rowCount ();
707
+ }
708
+
709
+ /**
710
+ * 获取最近插入的ID.
711
+ * @param string $sequence 自增序列名
712
+ *
713
+ * @return mixed
714
+ */
715
+ public function getAutoID (?string $ sequence = null )
716
+ {
717
+ try {
718
+ $ insertId = $ this ->linkID ->lastInsertId ($ sequence );
719
+ } catch (\Exception $ e ) {
720
+ $ insertId = '' ;
721
+ }
722
+
723
+ return $ insertId ;
705
724
}
706
725
707
726
/**
@@ -1747,13 +1766,7 @@ public function getLastSql(): string
1747
1766
*/
1748
1767
public function getLastInsID (BaseQuery $ query , ?string $ sequence = null )
1749
1768
{
1750
- try {
1751
- $ insertId = $ this ->linkID ->lastInsertId ($ sequence );
1752
- } catch (\Exception $ e ) {
1753
- $ insertId = '' ;
1754
- }
1755
-
1756
- return $ this ->autoInsIDType ($ query , $ insertId );
1769
+ return $ this ->autoInsIDType ($ query , $ this ->getAutoID ($ sequence ));
1757
1770
}
1758
1771
1759
1772
/**
0 commit comments