-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the return of queries executed in QFFQL
- Loading branch information
Showing
4 changed files
with
217 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Queryflatfile | ||
* | ||
* @license https://github.com/soosyze/queryflatfile/blob/master/LICENSE (MIT License) | ||
*/ | ||
|
||
namespace Queryflatfile; | ||
|
||
trait ValueToString | ||
{ | ||
/** | ||
* @param array|null|scalar|Where $value | ||
* | ||
* @return string | ||
*/ | ||
protected static function getValueToString($value): string | ||
{ | ||
if (is_int($value)) { | ||
return (string) $value; | ||
} | ||
if (is_string($value)) { | ||
return sprintf('\'%s\'', addslashes($value)); | ||
} | ||
if ($value instanceof Where) { | ||
return (string) $value; | ||
} | ||
if (is_array($value)) { | ||
return implode( | ||
', ', | ||
array_map( | ||
function ($item): string { | ||
return self::getValueToString($item); | ||
}, | ||
$value | ||
) | ||
); | ||
} | ||
|
||
return 'null'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters