33
44namespace MaplePHP \Query ;
55
6+ use MaplePHP \Query \Exceptions \ConnectException ;
67use MaplePHP \Query \Utility \Attr ;
7- use MaplePHP \Query \Handlers \MySqliHandler ;
88use MaplePHP \Query \Interfaces \AttrInterface ;
99use MaplePHP \Query \Interfaces \MigrateInterface ;
1010use MaplePHP \Query \Interfaces \DBInterface ;
@@ -284,7 +284,8 @@ final protected function getMainFKData(): array
284284
285285 /**
286286 * Mysql Prep/protect string
287- * @param mixed $val
287+ * @param mixed $val
288+ * @param bool $enclose
288289 * @return AttrInterface
289290 */
290291 final protected function prep (mixed $ val , bool $ enclose = true ): AttrInterface
@@ -347,15 +348,15 @@ final protected function camelLoop(array $camelCaseArr, array $valArr, callable
347348 */
348349 final protected function extractCamelCase (string $ value ): array
349350 {
350- $ arr = preg_split ('#([A-Z][^A-Z]*)# ' , $ value , 0 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
351- return $ arr ;
351+ return preg_split ('#([A-Z][^A-Z]*)# ' , $ value , 0 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
352352 }
353353
354354 /**
355355 * Build join data from Migrate data
356- * @param MigrateInterface $mig
357- * @param string $type Join type (INNER, LEFT, ...)
356+ * @param MigrateInterface $mig
357+ * @param string $type Join type (INNER, LEFT, ...)
358358 * @return array
359+ * @throws ConnectException
359360 */
360361 final protected function buildJoinFromMig (MigrateInterface $ mig , string $ type ): array
361362 {
@@ -370,16 +371,16 @@ final protected function buildJoinFromMig(MigrateInterface $mig, string $type):
370371 if (isset ($ row ['fk ' ])) {
371372 foreach ($ row ['fk ' ] as $ a ) {
372373 if ($ a ['table ' ] === (string )$ this ->table ) {
373- $ joinArr [] = "{ $ type} JOIN " . $ prefix . $ migTable . " " . $ migTable .
374- " ON ( " . $ migTable . ". { $ col} = {$ a ['table ' ]}. {$ a ['column ' ]}) " ;
374+ $ joinArr [] = "$ type JOIN " . $ prefix . $ migTable . " " . $ migTable .
375+ " ON ( " . $ migTable . ". $ col = {$ a ['table ' ]}. {$ a ['column ' ]}) " ;
375376 }
376377 }
377378 } else {
378379 foreach ($ main as $ c => $ a ) {
379380 foreach ($ a as $ t => $ d ) {
380381 if (in_array ($ col , $ d )) {
381- $ joinArr [] = "{ $ type} JOIN " . $ prefix . $ migTable . " " . $ migTable .
382- " ON ( { $ t } . { $ col} = { $ this ->alias } . { $ c } ) " ;
382+ $ joinArr [] = "$ type JOIN " . $ prefix . $ migTable . " " . $ migTable .
383+ " ON ( $ t . $ col = $ this ->alias . $ c ) " ;
383384 }
384385 }
385386 }
@@ -407,19 +408,21 @@ protected function getAllQueryTables(): ?string
407408
408409 /**
409410 * Query result
410- * @param string|self $sql
411- * @param string|null $method
412- * @param array $args
413- * @return array|object|bool
411+ * @param string|self $sql
412+ * @param string|null $method
413+ * @param array $args
414+ * @return array|object|bool|string
415+ * @throws DBQueryException
414416 */
415- final protected function query (string |self $ sql , ?string $ method = null , array $ args = []): array |object |bool
417+ final protected function query (string |self $ sql , ?string $ method = null , array $ args = []): array |object |bool | string
416418 {
417419 $ query = new Query ($ sql );
420+ $ query ->setPluck ($ this ->pluck );
418421 if (!is_null ($ method )) {
419422 if (method_exists ($ query , $ method )) {
420423 return call_user_func_array ([$ query , $ method ], $ args );
421424 }
422- throw new DBQueryException ("Method \"{ $ method} \" does not exists! " , 1 );
425+ throw new DBQueryException ("Method \"$ method \" does not exists! " , 1 );
423426 }
424427 return $ query ;
425428 }
0 commit comments