6
6
7
7
use Illuminate \Support \Carbon ;
8
8
use Libsql \Statement ;
9
+ use Libsql \Blob ;
9
10
10
11
class LibsqlStatement
11
12
{
@@ -62,7 +63,7 @@ public function query(array $parameters = []): mixed
62
63
}
63
64
64
65
$ results = $ this ->statement ->query ()->fetchArray ();
65
- $ rows = decodeDoubleBase64 ($ results );
66
+ $ rows = decode ($ results );
66
67
$ rowValues = array_values ($ rows );
67
68
68
69
return match ($ this ->mode ) {
@@ -79,7 +80,7 @@ public function query(array $parameters = []): mixed
79
80
$ this ->statement ->bind ([$ key => $ value ]);
80
81
}
81
82
$ result = $ this ->statement ->query ()->fetchArray ();
82
- $ rows = decodeDoubleBase64 ($ result );
83
+ $ rows = decode ($ result );
83
84
84
85
return match ($ this ->mode ) {
85
86
\PDO ::FETCH_ASSOC => collect ($ rows ),
@@ -91,27 +92,20 @@ public function query(array $parameters = []): mixed
91
92
92
93
public function execute (array $ parameters = []): bool
93
94
{
94
- try {
95
-
96
- if (empty ($ parameters )) {
97
- $ parameters = $ this ->bindings ;
98
- }
99
-
100
- foreach ($ parameters as $ key => $ value ) {
101
- $ this ->statement ->bind ([$ key => $ value ]);
102
- }
95
+ if (empty ($ parameters )) {
96
+ $ parameters = $ this ->parameterCasting ($ this ->bindings );
97
+ }
103
98
104
- if (str_starts_with (strtolower ($ this ->query ), 'select ' )) {
105
- $ queryRows = $ this ->statement ->query ()->fetchArray ();
106
- $ this ->affectedRows = count ($ queryRows );
107
- } else {
108
- $ this ->affectedRows = $ this ->statement ->execute ();
109
- }
99
+ $ this ->statement ->bind ($ parameters );
110
100
111
- return true ;
112
- } catch (\Exception $ e ) {
113
- return false ;
101
+ if (str_starts_with (strtolower ($ this ->query ), 'select ' )) {
102
+ $ queryRows = $ this ->statement ->query ()->fetchArray ();
103
+ $ this ->affectedRows = count ($ queryRows );
104
+ } else {
105
+ $ this ->affectedRows = $ this ->statement ->execute ();
114
106
}
107
+
108
+ return true ;
115
109
}
116
110
117
111
#[\ReturnTypeWillChange]
@@ -217,7 +211,7 @@ private function parameterCasting(array $parameters): array
217
211
};
218
212
219
213
if ($ type === 'blob ' ) {
220
- $ value = base64_encode ( base64_encode ( $ value) );
214
+ $ value = new Blob ( $ value );
221
215
}
222
216
223
217
if ($ type === 'boolean ' ) {
0 commit comments