X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=bde%2Ftrouver.sh;h=8f5031200ea7e3568d428b62217bd2e30dc3b1ed;hb=0ee4ad8cace762a5d6df6df34aa095d3cc20ac38;hp=920219f8ac206d507e3edce63357edaeb7d0c8ba;hpb=e06766c11f294c4c3db3d90e855bc313e6165cee;p=scripts-20-100.git diff --git a/bde/trouver.sh b/bde/trouver.sh index 920219f..8f50312 100755 --- a/bde/trouver.sh +++ b/bde/trouver.sh @@ -6,9 +6,15 @@ for i in $@ do if [ $i = "--no-mail" ] then nomail=1; + shift; fi; if [ $i = "--idbde" ] then searchidcbde=1; + shift; + fi + if [ $i = "--all" ] || [ $i = "-a" ] + then searchall=1; + shift; fi done @@ -17,11 +23,16 @@ if [ -z "${nomail}" ] then adding=" OR mail ILIKE '%$1%'" fi -# Si on a mis --idcbde, il faut matcher numcbde de manière plus lâche +# Si on a mis --idbde, il faut matcher l'idbde de manière plus lâche if [ "${searchidcbde}" = "1" ] then wild="%" fi -psql note -c "SELECT * FROM comptes WHERE pseudo ILIKE '%$1%' OR nom ILIKE '%$1%' - OR prenom ILIKE '%$1%'${adding} OR CAST(idbde AS varchar) LIKE '${wild}$1${wild}' ORDER BY nom;" + psql note -c "SELECT * FROM comptes WHERE pseudo ILIKE '%$1%' OR nom ILIKE '%$1%' + OR prenom ILIKE '%$1%'${adding} OR CAST(idbde AS varchar) LIKE '${wild}$1${wild}' ORDER BY nom;" +if [ -n "${searchall}" ] +then + psql note -c "SELECT a.*, c.* FROM aliases AS a, comptes AS c WHERE a.idbde = c.idbde AND a.alias ILIKE '%$1%' ORDER BY a.alias;" + psql note -c "SELECT h.*, c.* FROM historique AS h, comptes AS c WHERE h.idbde = c.idbde AND h.avant ILIKE '%$1%' ORDER BY h.avant;" +fi