Created
June 9, 2026 08:45
-
-
Save vyspiansky/f5029dda705e81a66351b1f8d6576b73 to your computer and use it in GitHub Desktop.
Assemble SQL query in Drupal 10
This file contains hidden or 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
| <?php | |
| /** @var \Drupal\Core\Database\Query\ExtendableInterface $query */ | |
| $sql = $query->__toString(); | |
| $args = $query->getArguments(); | |
| foreach ($args as $placeholder => $value) { | |
| $quoted = is_numeric($value) ? (string) $value : "'" . addslashes($value) . "'"; | |
| $sql = str_replace($placeholder, $quoted, $sql); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment