Created
July 17, 2012 13:20
-
-
Save irwinv/3129364 to your computer and use it in GitHub Desktop.
ajouter un alias à chaque tbl
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
/** | |
* Si La virgule est bien presente | |
* Dans le cas des evenements la requete apres le FROM sera : ... FROM table1, table2 d(-_-)b | |
**/ | |
if(preg_match('#,#', $strassoctbl)){ | |
$explode = explode(',', $strassoctbl); | |
//Decomposition des noms de tables pour ajouter les alias. | |
$f = 0; | |
foreach($explode as $key => $val){ | |
//Ajouter un alias à chaque table | |
switch($val){ | |
case "T_WC_EVENT": $alias = ' evt'; $tblcomplete['event'][$key] = $val.$alias; break; | |
case "T_WC_EVENT_TYPE": $alias = ' evtt'; $tblcomplete['event'][$key] = $val.$alias; break; | |
} | |
$depo[] = $tblcomplete['event'][$key]; | |
$f ++; | |
} | |
if($intdebug){ | |
print_r($depo); | |
exit; | |
} | |
//Formatage de la chaine à ajouter dans la requete | |
$tblout = implode(', ', $depo); | |
//Requete avec un espace à la fin pour la separer du WHERE. | |
$compo .= $tblout.chr(32); | |
} | |
//Dans le cas ou on a qu'une table ex : ... FROM table | |
else{ | |
$compo .= $strassoctbl; | |
} |
Author
irwinv
commented
Jul 17, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment