File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,6 +121,25 @@ public function lastSQL(): string
121121 return $ this ->last_sql ;
122122 }
123123
124+ /**
125+ * @inheritDoc
126+ */
127+ public function lastError (): ?string
128+ {
129+ if (!isset ($ this ->statement )){
130+ return null ;
131+ }
132+ $ errorCode = $ this ->statement ->errorCode ();
133+ if ($ errorCode === null || empty (\trim ($ errorCode , "0 \t\n\r\0\x0B" ))){
134+ return null ;
135+ }
136+ $ errorInfo = $ this ->statement ->errorInfo ();
137+ if (!isset ($ errorInfo [2 ])){
138+ return null ;
139+ }
140+ return $ errorCode . ' - ' . $ errorInfo [2 ];
141+ }
142+
124143 /**
125144 * @inheritDoc
126145 */
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ public function prepare(string $sqlQuery): self;
3232 */
3333 public function lastSQL (): string ;
3434
35+ /**
36+ * @return string|null
37+ */
38+ public function lastError (): ?string ;
39+
3540 /**
3641 * @param $value
3742 * @return mixed
You can’t perform that action at this time.
0 commit comments