77 * @author Muhammet ŞAFAK <info@muhammetsafak.com.tr>
88 * @copyright Copyright © 2022 Muhammet ŞAFAK
99 * @license ./LICENSE MIT
10- * @version 1.1.9
10+ * @version 1.1.10
1111 * @link https://www.muhammetsafak.com.tr
1212 */
1313
@@ -100,23 +100,21 @@ public function __call($name, $arguments)
100100 if (Helper::str_starts_with ($ name , 'findBy ' )){
101101 $ attrCamelCase = \substr ($ name , 6 );
102102 $ attributeName = Helper::attributeNameCamelCaseDecode ($ attrCamelCase );
103-
104- $ this ->getQueryBuilder ()->where ($ attributeName , ': ' . $ attributeName );
103+ $ this ->getQueryBuilder ()->where ($ attributeName , $ arguments [0 ]);
105104 $ query = $ this ->getQueryBuilder ()->readQuery ();
106105 $ this ->getQueryBuilder ()->reset ();
107- $ this ->getDataMapper ()->setParameter (': ' . $ attributeName , $ arguments [0 ]);
108106 $ this ->getDataMapper ()->persist ($ query , []);
109- return $ this ->getDataMapper ()->numRows () > 0 ? $ this ->getDataMapper ()->results () : [];
107+ $ res = $ this ->getDataMapper ()->results ();
108+ return $ res === null ? [] : $ res ;
110109 }
111110 if (Helper::str_starts_with ($ name , 'findOneBy ' )){
112111 $ attrCamelCase = \substr ($ name , 9 );
113112 $ attributeName = Helper::attributeNameCamelCaseDecode ($ attrCamelCase );
114- $ this ->getDataMapper ()->setParameter (': ' . $ attributeName , $ arguments [0 ]);
115- $ this ->getQueryBuilder ()->where ($ attributeName , ': ' . $ attributeName );
113+ $ this ->getQueryBuilder ()->where ($ attributeName , $ arguments [0 ]);
116114 $ query = $ this ->getQueryBuilder ()->readQuery ();
117115 $ this ->getQueryBuilder ()->reset ();
118116 $ this ->getDataMapper ()->persist ($ query , []);
119- return $ this ->getDataMapper ()->numRows () > 0 ? $ this -> getDataMapper ()-> result () : null ;
117+ return $ this ->getDataMapper ()->result (); ;
120118 }
121119 if (\method_exists ($ this ->_queryBuilder , $ name )){
122120 $ res = $ this ->getQueryBuilder ()->{$ name }(...$ arguments );
@@ -294,7 +292,8 @@ public function create(array $fields)
294292 public function read (array $ selector = [], array $ conditions = [], array $ parameters = []): array
295293 {
296294 $ this ->readQueryHandler ($ selector , $ conditions , $ parameters );
297- return $ this ->getDataMapper ()->numRows () > 0 ? $ this ->getDataMapper ()->results () : [];
295+ $ res = $ this ->getDataMapper ()->results ();
296+ return $ res === null ? [] : $ res ;
298297 }
299298
300299 /**
@@ -307,7 +306,7 @@ public function readOne(array $selector = [], array $conditions = [], array $par
307306 {
308307 $ this ->getQueryBuilder ()->limit (1 );
309308 $ this ->readQueryHandler ($ selector , $ conditions , $ parameters );
310- return $ this ->getDataMapper ()->numRows () > 0 ? $ this -> getDataMapper ()-> result () : null ;
309+ return $ this ->getDataMapper ()->result ();
311310 }
312311
313312 /**
@@ -319,8 +318,7 @@ public function update(array $fields)
319318 $ schemaID = null ;
320319 if (!empty ($ this ->getSchemaID ()) && isset ($ fields [$ this ->getSchemaID ()])){
321320 $ schemaID = $ fields [$ this ->getSchemaID ()];
322- $ this ->getQueryBuilder ()->where ($ this ->getSchemaID (), ': ' . $ this ->getSchemaID ());
323- $ this ->getDataMapper ()->setParameter (': ' . $ this ->getSchemaID (), $ schemaID );
321+ $ this ->getQueryBuilder ()->where ($ this ->getSchemaID (), ': ' . $ schemaID );
324322 unset($ fields [$ this ->getSchemaID ()]);
325323 }
326324 if (empty ($ fields )){
@@ -333,12 +331,10 @@ public function update(array $fields)
333331 $ this ->errors [] = $ this ->getValidation ()->getError ();
334332 return false ;
335333 }
336- $ data [$ column ] = ': ' . $ column ;
337- $ this ->getDataMapper ()->setParameter (': ' . $ column , $ value );
334+ $ data [$ column ] = $ value ;
338335 }
339336 if (!empty ($ this ->configurations ['updatedField ' ])){
340- $ data [$ this ->configurations ['updatedField ' ]] = ': ' . $ this ->configurations ['updatedField ' ];
341- $ this ->getDataMapper ()->setParameter (': ' . $ this ->configurations ['updatedField ' ], \date ($ this ->configurations ['timestampFormat ' ]));
337+ $ data [$ this ->configurations ['updatedField ' ]] = \date ($ this ->configurations ['timestampFormat ' ]);
342338 }
343339 $ query = $ this ->getQueryBuilder ()->updateQuery ($ data );
344340 $ this ->getQueryBuilder ()->reset ();
@@ -354,8 +350,7 @@ public function update(array $fields)
354350 public function delete (array $ conditions = [])
355351 {
356352 foreach ($ conditions as $ column => $ value ) {
357- $ this ->getQueryBuilder ()->where ($ column , ': ' .$ column );
358- $ this ->getDataMapper ()->setParameter (': ' .$ column , $ value );
353+ $ this ->getQueryBuilder ()->where ($ column , $ value );
359354 }
360355 if (!empty ($ this ->configurations ['deletedField ' ])){
361356 if ($ this ->isOnlyDeletes !== FALSE ){
@@ -364,9 +359,8 @@ public function delete(array $conditions = [])
364359 $ this ->isOnlyDeletes = false ;
365360 }else {
366361 $ this ->getQueryBuilder ()->is ($ this ->configurations ['deletedField ' ], null );
367- $ this ->getDataMapper ()->setParameter (': ' . $ this ->configurations ['deletedField ' ], \date ($ this ->configurations ['timestampFormat ' ]));
368362 $ query = $ this ->getQueryBuilder ()->updateQuery ([
369- $ this ->configurations ['deletedField ' ] => ' : ' . $ this ->configurations ['deletedField ' ] ,
363+ $ this ->configurations ['deletedField ' ] => \date ( $ this ->configurations ['timestampFormat ' ]) ,
370364 ]);
371365 }
372366 }else {
@@ -402,7 +396,7 @@ public function count(bool $builder_reset = false): int
402396 if ($ builder_reset !== FALSE ){
403397 $ this ->getQueryBuilder ()->reset ();
404398 }
405- $ parameters = $ this ->getDataMapper ()->getParameters ();
399+ $ parameters = $ this ->getDataMapper ()->getParameters (false );
406400 $ this ->getDataMapper ()->persist ($ query , []);
407401 if ($ builder_reset === FALSE && !empty ($ parameters )){
408402 $ this ->getDataMapper ()->setParameters ($ parameters );
@@ -478,8 +472,7 @@ private function readQueryHandler(array $selector = [], array $conditions = [],
478472 }
479473 if (!empty ($ conditions )){
480474 foreach ($ conditions as $ column => $ value ) {
481- $ this ->getQueryBuilder ()->where ($ column , ': ' .$ column );
482- $ this ->getDataMapper ()->setParameter (': ' . $ column , $ value );
475+ $ this ->getQueryBuilder ()->where ($ column , $ value );
483476 }
484477 }
485478 $ this ->deletedFieldBuild ();
0 commit comments