Go to most recent revision | Blame | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- template designed by Marco Von Ballmoos -->
<title>File Source for Modele.php</title>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
<link rel="stylesheet" href="../media/stylesheet.css" />
</head>
<body>
<h1>Source for file Modele.php</h1>
<p>Documentation is available at <a href="../Framework/_Modele.php.html">Modele.php</a></p>
<div class="src-code">
<div class="src-code"><ol><li><div class="src-line"><a name="a1"></a><span class="src-php"><?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-comm">// declare(encoding='UTF-8');</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">* Classe modèle, donc d'accés au données, elle ne devrait pas être appelée de l'extérieur.</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">* Elle fait office d'abstraction légère de base de données en utilisant diveres possibilités</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">* d'abstraction de base de données (PDO, mysql, mysqli, sqlite)</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc">* Elle est abstraite donc doit obligatoirement être étendue.</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-doc">*</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-doc">* PHP Version 5</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-doc">*</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-doc">* </span><span class="src-doc-coretag">@category</span><span class="src-doc"> Class</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-doc">* </span><span class="src-doc-coretag">@package</span><span class="src-doc"> Framework</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-doc">* </span><span class="src-doc-coretag">@author</span><span class="src-doc"> aurelien <aurelien@tela-botanica.org></span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-doc">* </span><span class="src-doc-coretag">@copyright</span><span class="src-doc"> 2009 Tela-Botanica</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-doc">* </span><span class="src-doc-coretag">@license</span><span class="src-doc"> http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-doc">* </span><span class="src-doc-coretag">@license</span><span class="src-doc"> http://www.gnu.org/licenses/gpl.html Licence GNU-GPL</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-doc">* </span><span class="src-doc-coretag">@version</span><span class="src-doc"> SVN: $$Id: Modele.php 145 2010-03-02 17:23:09Z jpm $$</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-doc">* </span><span class="src-doc-coretag">@link</span><span class="src-doc"> /doc/framework/</span></div></li>
<li><div class="src-line"><a name="a19"></a><span class="src-doc">*</span></div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-doc">*/</span></div></li>
<li><div class="src-line"><a name="a21"></a><span class="src-key">abstract </span><span class="src-key">class </span><a href="../Framework/Modele.html">Modele</a> <span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a22"></a> </div></li>
<li><div class="src-line"><a name="a23"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a24"></a><span class="src-doc"> * Mode de fetch associatif</span></div></li>
<li><div class="src-line"><a name="a25"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a26"></a> <span class="src-key">private </span><span class="src-var">$ASSOC </span>= <span class="src-str">''</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a27"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a28"></a><span class="src-doc"> * Mode de fetch objet</span></div></li>
<li><div class="src-line"><a name="a29"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a30"></a> <span class="src-key">private </span><span class="src-var">$OBJECT </span>= <span class="src-str">''</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a31"></a> </div></li>
<li><div class="src-line"><a name="a32"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a33"></a><span class="src-doc"> * abstraction de base de données utilisée</span></div></li>
<li><div class="src-line"><a name="a34"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a35"></a> <span class="src-key">private </span><span class="src-var">$abstraction</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a36"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a37"></a><span class="src-doc"> * registre global</span></div></li>
<li><div class="src-line"><a name="a38"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a39"></a> <span class="src-key">private </span><span class="src-var">$registre</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a40"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a41"></a><span class="src-doc"> * DSN pour accéder à la base de données</span></div></li>
<li><div class="src-line"><a name="a42"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a43"></a> <span class="src-key">private </span><span class="src-var">$dsn</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a44"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a45"></a><span class="src-doc"> * Type de base de données (mysql, mysqli, etc ...)</span></div></li>
<li><div class="src-line"><a name="a46"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a47"></a> <span class="src-key">private </span><span class="src-var">$type</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a48"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a49"></a><span class="src-doc"> * Hote herbergeant la base de données</span></div></li>
<li><div class="src-line"><a name="a50"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a51"></a> <span class="src-key">private </span><span class="src-var">$hote</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a52"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a53"></a><span class="src-doc"> * Nom de la base de données à laquelle le modèle doit se connecter</span></div></li>
<li><div class="src-line"><a name="a54"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a55"></a> <span class="src-key">private </span><span class="src-var">$bdd_nom</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a56"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a57"></a><span class="src-doc"> * Nom d'utilisateur</span></div></li>
<li><div class="src-line"><a name="a58"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a59"></a> <span class="src-key">private </span><span class="src-var">$utilisateur</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a60"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a61"></a><span class="src-doc"> * Mot de passe</span></div></li>
<li><div class="src-line"><a name="a62"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a63"></a> <span class="src-key">private </span><span class="src-var">$pass</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a64"></a> </div></li>
<li><div class="src-line"><a name="a65"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a66"></a><span class="src-doc"> * Encodage de la base de données</span></div></li>
<li><div class="src-line"><a name="a67"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a68"></a> <span class="src-key">private </span><span class="src-var">$encodage </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a69"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a70"></a><span class="src-doc"> * Connexion à la base de données</span></div></li>
<li><div class="src-line"><a name="a71"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a72"></a> <span class="src-key">private </span><span class="src-var">$connexion </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a73"></a> </div></li>
<li><div class="src-line"><a name="a74"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a75"></a><span class="src-doc"> * Constructeur par défaut, appelé à l'initialisation.</span></div></li>
<li><div class="src-line"><a name="a76"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a77"></a> <span class="src-key">public </span><span class="src-key">function </span><a href="../Framework/Modele.html#method__construct">__construct</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a78"></a> <span class="src-comm">// les différents paramètres nécessaires sont lus à partir du registre</span></div></li>
<li><div class="src-line"><a name="a79"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">registre </span>= <span class="src-id"><a href="../Framework/Registre.html">Registre</a></span><span class="src-sym">::</span><a href="../Framework/Registre.html#methodgetInstance">getInstance</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a80"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction </span>= <a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_abstraction'</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a81"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">type </span>= <span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_protocole'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a82"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">hote </span>= <span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_serveur'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a83"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">bdd_nom </span>= <span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_nom'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a84"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">utilisateur </span>= <span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_utilisateur'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a85"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">pass </span>= <span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_mot_de_passe'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a86"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">encodage </span>= <span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'bdd_encodage'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a87"></a> </div></li>
<li><div class="src-line"><a name="a88"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">dsn </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">type</span>.<span class="src-str">':dbname='</span>.<span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">bdd_nom</span>.<span class="src-str">';host='</span>.<span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">hote</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a89"></a> <span class="src-var">$this</span><span class="src-sym">-></span><a href="../Framework/Modele.html#methodinitialiserProtocole">initialiserProtocole</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a90"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a91"></a> </div></li>
<li><div class="src-line"><a name="a92"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a93"></a><span class="src-doc"> * Connection à la base de données en utilisant les informations fournies par</span></div></li>
<li><div class="src-line"><a name="a94"></a><span class="src-doc"> * le fichier de configuration.</span></div></li>
<li><div class="src-line"><a name="a95"></a><span class="src-doc"> * private et final car n'a pas vocation a être appelée par l'utilisateur.</span></div></li>
<li><div class="src-line"><a name="a96"></a><span class="src-doc"> *</span></div></li>
<li><div class="src-line"><a name="a97"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@throws</span><span class="src-doc"> Exception une exception dans le cas ou là connexion échoue</span></div></li>
<li><div class="src-line"><a name="a98"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a99"></a> <span class="src-key">final </span><span class="src-key">private </span><span class="src-key">function </span><span class="src-id">connecter</span><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a100"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a101"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a102"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>= <span class="src-key">new </span><span class="src-id">PDO</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">dsn</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">utilisateur</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">pass</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a103"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a104"></a> </div></li>
<li><div class="src-line"><a name="a105"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a106"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>= <a href="http://www.php.net/mysql_connect">mysql_connect</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">hote</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">utilisateur</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">pass</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a107"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>!= <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a108"></a> <a href="http://www.php.net/mysql_select_db">mysql_select_db</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">bdd_nom</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a109"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a110"></a> throw <span class="src-key">new </span><span class="src-id">Exception</span><span class="src-sym">(</span><span class="src-str">'Erreur de connexion à la base de données, vérifiez les paramètres du fichier de configuration'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a111"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a112"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a113"></a> </div></li>
<li><div class="src-line"><a name="a114"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a115"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>= <span class="src-key">new </span><span class="src-id">mysqli</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">hote</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">utilisateur</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">pass</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">bdd_nom</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a116"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a117"></a> throw <span class="src-key">new </span><span class="src-id">Exception</span><span class="src-sym">(</span><span class="src-str">'Erreur de connexion à la base de données, vérifiez les paramètres du fichier de configuration'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a118"></a> <span class="src-key">return</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a119"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a120"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a121"></a> </div></li>
<li><div class="src-line"><a name="a122"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a123"></a> <span class="src-comm">// cas particulier de sqllite, on considère que le nom de la base de données correspond au fichier à ouvrir</span></div></li>
<li><div class="src-line"><a name="a124"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>= <span class="src-key">new </span><span class="src-id">SQLite3</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">bdd_nom</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a125"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a126"></a> throw <span class="src-key">new </span><span class="src-id">Exception</span><span class="src-sym">(</span><span class="src-str">'Erreur de connexion à la base de données, vérifiez les paramètres du fichier de configuration'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a127"></a> <span class="src-key">return</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a128"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a129"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a130"></a> </div></li>
<li><div class="src-line"><a name="a131"></a> <span class="src-key">default</span>:</div></li>
<li><div class="src-line"><a name="a132"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a133"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a134"></a> </div></li>
<li><div class="src-line"><a name="a135"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">encodage </span>!= <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a136"></a> <span class="src-var">$this</span><span class="src-sym">-></span><a href="../Framework/Modele.html#methodrequete">requete</a><span class="src-sym">(</span><span class="src-str">"SET names '"</span>.<span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">encodage</span>.<span class="src-str">"'"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a137"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a138"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a139"></a> </div></li>
<li><div class="src-line"><a name="a140"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a141"></a><span class="src-doc"> * Fonction qui appelle la bonne fonction pour executer une requête suivant le type de bdd.</span></div></li>
<li><div class="src-line"><a name="a142"></a><span class="src-doc"> *</span></div></li>
<li><div class="src-line"><a name="a143"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc">la requete à effectuer</span></div></li>
<li><div class="src-line"><a name="a144"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">PDOStatement </span><span class="src-doc">un objet contenant le résultat de la requête</span></div></li>
<li><div class="src-line"><a name="a145"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a146"></a> <span class="src-key">final </span><span class="src-key">protected </span><span class="src-key">function </span><a href="../Framework/Modele.html#methodrequete">requete</a><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a147"></a> <span class="src-comm">// on ne se connecte que lors du premier appel à une requete (lazy connexion)</span></div></li>
<li><div class="src-line"><a name="a148"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>== <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a149"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-id">connecter</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a150"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a151"></a> </div></li>
<li><div class="src-line"><a name="a152"></a> <span class="src-var">$retour </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a153"></a> </div></li>
<li><div class="src-line"><a name="a154"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a155"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a156"></a> <span class="src-var">$retour </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a157"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a158"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a159"></a> <span class="src-var">$retour </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a160"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a161"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a162"></a> <span class="src-var">$retour </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a163"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a164"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a165"></a> <span class="src-var">$retour </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a166"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a167"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a168"></a> </div></li>
<li><div class="src-line"><a name="a169"></a> <span class="src-key">return </span><span class="src-var">$retour</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a170"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a171"></a> </div></li>
<li><div class="src-line"><a name="a172"></a> <span class="src-key">final </span><span class="src-key">protected </span><span class="src-key">function </span><a href="../Framework/Modele.html#methodrequeteUn">requeteUn</a><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">,</span><span class="src-var">$mode </span>= <span class="src-str">'ASSOC'</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a173"></a> <span class="src-comm">// Connection seulement lors du premier appel à une requete (lazy connexion)</span></div></li>
<li><div class="src-line"><a name="a174"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>== <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a175"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-id">connecter</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a176"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a177"></a> </div></li>
<li><div class="src-line"><a name="a178"></a> <span class="src-var">$retour </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a179"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a180"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a181"></a> <span class="src-var">$res_req </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a182"></a> <span class="src-var">$retour </span>=<span class="src-var">$res_req</span><span class="src-sym">-></span><span class="src-id">fetch</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">$mode</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a183"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a184"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a185"></a> <span class="src-var">$res </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">,</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a186"></a> <span class="src-var">$fonction_fetch </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">$mode</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a187"></a> <span class="src-var">$retour </span>= <span class="src-var">$fonction_fetch</span><span class="src-sym">(</span><span class="src-var">$res</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a188"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a189"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a190"></a> <span class="src-var">$res </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a191"></a> <span class="src-var">$fonction_fetch </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">$mode</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a192"></a> <span class="src-var">$retour </span>= <span class="src-var">$res</span><span class="src-sym">-></span><span class="src-var">$fonction_fetch</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a193"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a194"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a195"></a> <span class="src-var">$retour </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">querySingle</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a196"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a197"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a198"></a> </div></li>
<li><div class="src-line"><a name="a199"></a> <span class="src-key">return </span><span class="src-var">$retour</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a200"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a201"></a> </div></li>
<li><div class="src-line"><a name="a202"></a> </div></li>
<li><div class="src-line"><a name="a203"></a> <span class="src-key">final </span><span class="src-key">protected </span><span class="src-key">function </span><a href="../Framework/Modele.html#methodrequeteTous">requeteTous</a><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">,</span><span class="src-var">$mode </span>= <span class="src-str">'ASSOC'</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a204"></a> <span class="src-comm">// Connexion seulement lors du premier appel à une requete (lazy connexion)</span></div></li>
<li><div class="src-line"><a name="a205"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>== <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a206"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-id">connecter</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a207"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a208"></a> </div></li>
<li><div class="src-line"><a name="a209"></a> <span class="src-var">$retour </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a210"></a> </div></li>
<li><div class="src-line"><a name="a211"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a212"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a213"></a> try <span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a214"></a> <span class="src-var">$res_req </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a215"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$res_req </span>!== <span class="src-id">false</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a216"></a> <span class="src-var">$retour </span>= <span class="src-var">$res_req</span><span class="src-sym">-></span><span class="src-id">fetchAll</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">$mode</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a217"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a218"></a> <span class="src-var">$retour </span>= <span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a219"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a220"></a> <span class="src-sym">} </span>catch <span class="src-sym">(</span><span class="src-id">PDOException </span><span class="src-var">$e</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a221"></a> <span class="src-var">$message </span>= <span class="src-str">'Requête echec. Fichier : "%s". Ligne : "%s". Message : %s'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a222"></a> <a href="http://www.php.net/trigger_error">trigger_error</a><span class="src-sym">(</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-var">$message</span><span class="src-sym">, </span><span class="src-var">$e</span><span class="src-sym">-></span><span class="src-id">getFile</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-var">$e</span><span class="src-sym">-></span><span class="src-id">getLine</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-var">$e</span><span class="src-sym">-></span><span class="src-id">getMessage</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">, </span><span class="src-id">E_US
ER_WARNING</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a223"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a224"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a225"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a226"></a> <span class="src-var">$res </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a227"></a> <span class="src-var">$fonction_fetch </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">$mode</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a228"></a> <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$ligne </span>= <span class="src-var">$fonction_fetch</span><span class="src-sym">(</span><span class="src-var">$res</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a229"></a> <span class="src-var">$retour</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-var">$ligne</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a230"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a231"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a232"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a233"></a> <span class="src-var">$res </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a234"></a> <span class="src-var">$function_fetch </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">$mode</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a235"></a> <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$ligne </span>= <span class="src-var">$res</span><span class="src-sym">-></span><span class="src-var">$function_fetch</span><span class="src-sym">(</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a236"></a> <span class="src-var">$retour</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-var">$ligne</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a237"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a238"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a239"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a240"></a> <span class="src-var">$res </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$requete</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a241"></a> <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$ligne </span>= <span class="src-var">$res</span><span class="src-sym">-></span><span class="src-id">fetch_array</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">ASSOC</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a242"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$mode </span>== <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">ASSOC</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a243"></a> <span class="src-var">$retour</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-var">$ligne</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a244"></a> <span class="src-sym">} </span><span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-var">$mode </span>== <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">OBJECT</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a245"></a> <span class="src-comm">// cas particulier de sqllite</span></div></li>
<li><div class="src-line"><a name="a246"></a> <span class="src-comm">// qui n'a pas de fonction fetch_object</span></div></li>
<li><div class="src-line"><a name="a247"></a> <span class="src-var">$ligneObjet </span>= <span class="src-key">new </span><span class="src-id">stdClass</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a248"></a> <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$ligne </span><span class="src-key">as </span><span class="src-var">$colonne </span>=> <span class="src-var">$valeur</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a249"></a> <span class="src-var">$ligneObjet</span><span class="src-sym">-></span><span class="src-var">$colonne </span>= <span class="src-var">$valeur</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a250"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a251"></a> <span class="src-var">$retour</span><span class="src-sym">[</span><span class="src-sym">] </span>= <span class="src-var">$ligneObjet</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a252"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a253"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a254"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a255"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a256"></a> </div></li>
<li><div class="src-line"><a name="a257"></a> <span class="src-key">return </span><span class="src-var">$retour</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a258"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a259"></a> </div></li>
<li><div class="src-line"><a name="a260"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a261"></a><span class="src-doc"> * protège une chaine de caractères avant l'insertion dans la base de données</span></div></li>
<li><div class="src-line"><a name="a262"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a263"></a> <span class="src-key">final </span><span class="src-key">protected </span><span class="src-key">function </span><a href="../Framework/Modele.html#methodproteger">proteger</a><span class="src-sym">(</span><span class="src-var">$chaine</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a264"></a> </div></li>
<li><div class="src-line"><a name="a265"></a> <span class="src-comm">// on ne se connecte que lors du premier appel à une requete</span></div></li>
<li><div class="src-line"><a name="a266"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>== <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a267"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-id">connecter</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a268"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a269"></a> </div></li>
<li><div class="src-line"><a name="a270"></a> <span class="src-var">$retour </span>= <span class="src-var">$chaine</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a271"></a> </div></li>
<li><div class="src-line"><a name="a272"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a273"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a274"></a> <span class="src-var">$retour </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">quote</span><span class="src-sym">(</span><span class="src-var">$chaine</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a275"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a276"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a277"></a> <span class="src-var">$retour </span>= <span class="src-str">'"'</span>.<a href="http://www.php.net/mysql_real_escape_string">mysql_real_escape_string</a><span class="src-sym">(</span><span class="src-var">$chaine</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">)</span>.<span class="src-str">'"'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a278"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a279"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a280"></a> <span class="src-var">$retour </span>= <span class="src-str">'"'</span>.<span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">real_escape_string</span><span class="src-sym">(</span><span class="src-var">$chaine</span><span class="src-sym">)</span>.<span class="src-str">'"'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a281"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a282"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a283"></a> <span class="src-var">$retour </span>= <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">escapeString</span><span class="src-sym">(</span><span class="src-var">$chaine</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a284"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a285"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a286"></a> </div></li>
<li><div class="src-line"><a name="a287"></a> <span class="src-key">return </span><span class="src-var">$retour</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a288"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a289"></a> </div></li>
<li><div class="src-line"><a name="a290"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a291"></a><span class="src-doc"> * initialise les constantes de classe à leur bonne valeur</span></div></li>
<li><div class="src-line"><a name="a292"></a><span class="src-doc"> * et lance une exception si le protocole n'est pas bien défini</span></div></li>
<li><div class="src-line"><a name="a293"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@throws</span><span class="src-doc"> Exception</span></div></li>
<li><div class="src-line"><a name="a294"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a295"></a> <span class="src-key">final </span><span class="src-key">public </span><span class="src-key">function </span><a href="../Framework/Modele.html#methodinitialiserProtocole">initialiserProtocole</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a296"></a> </div></li>
<li><div class="src-line"><a name="a297"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a298"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a299"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">ASSOC </span>= <span class="src-id">PDO</span><span class="src-sym">::</span><span class="src-id">FETCH_ASSOC</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a300"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">OBJECT </span>= <span class="src-id">PDO</span><span class="src-sym">::</span><span class="src-id">FETCH_CLASS</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a301"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a302"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a303"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">ASSOC </span>= <span class="src-str">'mysql_fetch_assoc'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a304"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">OBJECT </span>= <span class="src-str">'mysql_fetch_object'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a305"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a306"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a307"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">ASSOC </span>= <span class="src-str">'fetch_assoc'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a308"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">OBJECT </span>= <span class="src-str">'fetch_object'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a309"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a310"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a311"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">ASSOC </span>= <span class="src-str">'SQLITE3_ASSOC'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a312"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">OBJECT </span>= <span class="src-str">'SQLITE3_OBJECT'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a313"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a314"></a> <span class="src-key">default</span>:</div></li>
<li><div class="src-line"><a name="a315"></a> throw <span class="src-key">new </span><span class="src-id">Exception</span><span class="src-sym">(</span><span class="src-str">'Erreur : l\'abstraction '</span>.<span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span>.<span class="src-str">' n\'est pas prise en charge'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a316"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a317"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a318"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a319"></a> </div></li>
<li><div class="src-line"><a name="a320"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a321"></a><span class="src-doc"> * Destructeur de classe, se contente de fermer explicitement la connexion</span></div></li>
<li><div class="src-line"><a name="a322"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a323"></a> <span class="src-key">final </span><span class="src-key">public </span><span class="src-key">function </span><a href="../Framework/Modele.html#method__destruct">__destruct</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a324"></a> <span class="src-key">switch </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">abstraction</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a325"></a> <span class="src-key">case </span><span class="src-str">'pdo'</span>:</div></li>
<li><div class="src-line"><a name="a326"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a327"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a328"></a> <span class="src-key">case </span><span class="src-str">'mysql'</span>:</div></li>
<li><div class="src-line"><a name="a329"></a> <span class="src-key">return </span><a href="http://www.php.net/mysql_close">mysql_close</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a330"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a331"></a> <span class="src-key">case </span><span class="src-str">'mysqli'</span>:</div></li>
<li><div class="src-line"><a name="a332"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">close</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a333"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a334"></a> <span class="src-key">case </span><span class="src-str">'sqlite3'</span>:</div></li>
<li><div class="src-line"><a name="a335"></a> <span class="src-var">$this</span><span class="src-sym">-></span><span class="src-var">connexion</span><span class="src-sym">-></span><span class="src-id">close</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a336"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a337"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a338"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a339"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a340"></a><span class="src-php">?></span></div></li>
</ol></div>
</div>
<p class="notes" id="credit">
Documentation generated on Thu, 04 Mar 2010 19:27:25 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</body>
</html>