Skip to content

Instantly share code, notes, and snippets.

@mnvx
Created September 12, 2019 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnvx/b24ac480be377b106b4e8538a27ba0ae to your computer and use it in GitHub Desktop.
Save mnvx/b24ac480be377b106b4e8538a27ba0ae to your computer and use it in GitHub Desktop.
test query
<?php
$pdo = new \PDO('pgsql:host=localhost;dbname=postgres', 'postgres', 'postgres');
$sql = <<<SQL
SELECT *
FROM (
SELECT 'CHAC TECHNOLOG*' as alias
UNION
SELECT 'KINDERY LIGHTING SALES DE?T*'
) m
JOIN (
SELECT 'CHACTECHNOLOGICO' as ie_clean
UNION
SELECT 'KINDERYLIGHTINGSALESDEPT' as ie_clean
) t ON t.ie_clean ILIKE REPLACE(REPLACE(REPLACE(m.alias, '*', '%'), '?', '_'), ' ', '')
ORDER BY ie_clean;
SQL;
echo $sql . PHP_EOL . PHP_EOL;
$stmt = $pdo->query($sql);
//$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
print_r($stmt->fetchAll(\PDO::FETCH_ASSOC));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment