66
77use Illuminate \Support \Carbon ;
88use Libsql \Statement ;
9+ use Libsql \Blob ;
910
1011class LibsqlStatement
1112{
@@ -62,7 +63,7 @@ public function query(array $parameters = []): mixed
6263 }
6364
6465 $ results = $ this ->statement ->query ()->fetchArray ();
65- $ rows = decodeDoubleBase64 ($ results );
66+ $ rows = decode ($ results );
6667 $ rowValues = array_values ($ rows );
6768
6869 return match ($ this ->mode ) {
@@ -79,7 +80,7 @@ public function query(array $parameters = []): mixed
7980 $ this ->statement ->bind ([$ key => $ value ]);
8081 }
8182 $ result = $ this ->statement ->query ()->fetchArray ();
82- $ rows = decodeDoubleBase64 ($ result );
83+ $ rows = decode ($ result );
8384
8485 return match ($ this ->mode ) {
8586 \PDO ::FETCH_ASSOC => collect ($ rows ),
@@ -91,27 +92,20 @@ public function query(array $parameters = []): mixed
9192
9293 public function execute (array $ parameters = []): bool
9394 {
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+ }
10398
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 );
110100
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 ();
114106 }
107+
108+ return true ;
115109 }
116110
117111 #[\ReturnTypeWillChange]
@@ -217,7 +211,7 @@ private function parameterCasting(array $parameters): array
217211 };
218212
219213 if ($ type === 'blob ' ) {
220- $ value = base64_encode ( base64_encode ( $ value) );
214+ $ value = new Blob ( $ value );
221215 }
222216
223217 if ($ type === 'boolean ' ) {
0 commit comments