<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.llaumgui.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Le blog de llaumgui - Balise - SGBD</title>
  <link>http://www.llaumgui.com/</link>
  <atom:link href="http://www.llaumgui.com/feed/tag/SGBD/rss2" rel="self" type="application/rss+xml"/>
  <description>Linux en général, Fedora en particulier...</description>
  <language>fr</language>
  <pubDate>Thu, 21 Aug 2008 02:39:04 +0200</pubDate>
  <copyright>http://creativecommons.org/licenses/by-nc-nd/2.5/</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>php, base de données et couche d'abstraction 3 (Driver MySQL)</title>
    <link>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-1-driver-mysql</link>
    <guid isPermaLink="false">urn:md5:6c067e3ac1b6e6400b14c9b035b96882</guid>
    <pubDate>Sat, 05 Feb 2005 00:25:00 +0000</pubDate>
    <dc:creator>llaumgui</dc:creator>
        <category>Développement web</category>
        <category>MySQL</category><category>php</category><category>SGBD</category>    
    <description>&lt;p&gt;Je viens de porter quelques retouches à mes driver MySQL (Ceux que j'utilise pour PortaLL mon portail perso). J'en profite donc pour vous les présenter.
A noter que je n'ai pas encore testé l'abstraction avec un autre SGBD, mais normalement tout devrait aller très bien ;-).&lt;/p&gt;    &lt;p&gt;Au programme des fonctionnalités :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Connexion/déconnexion.&lt;/li&gt;
&lt;li&gt;Fonctions de base MySQL.&lt;/li&gt;
&lt;li&gt;Compteur de requête.&lt;/li&gt;
&lt;li&gt;Liste des requêtes effectuées par une page.&lt;/li&gt;
&lt;li&gt;Mise en forme des requêtes avant de les afficher pour une lecture et un débogage  facilités.&lt;/li&gt;
&lt;/ul&gt;
&lt;code class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*-------------------------------------------------------------------------&lt;br /&gt;
| &amp;nbsp; PortaLL 2.1.&lt;br /&gt;
========================================&lt;br /&gt;
| &amp;nbsp; Par LLaumgui&lt;br /&gt;
| &amp;nbsp; (c) 2004&lt;br /&gt;
========================================&lt;br /&gt;
| &amp;nbsp; Web: http://www.xperience-fr.net&lt;br /&gt;
| &amp;nbsp; eMail: llaumgui_AT_xperience-fr.net&lt;br /&gt;
+-------------------------------------------------------------------------- */&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
* Gestion des relation avec une base de données mySQL.&lt;br /&gt;
* @package portall&lt;br /&gt;
* @author LLaumgui&lt;br /&gt;
* @version $Id&lt;br /&gt;
*/&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; DataBase &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$data&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;db_host&amp;quot;&lt;/span&gt; &amp;nbsp; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;db_login&amp;quot;&lt;/span&gt; &amp;nbsp;=&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;db_pass&amp;quot;&lt;/span&gt; &amp;nbsp; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;db_name&amp;quot;&lt;/span&gt; &amp;nbsp; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;debug_mod&amp;quot;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Information présente dans la conf_global.php.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// La requête.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$listQuery&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// La liste des requêtes (débug mod = 2).&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$connectionServer&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Connexion au serveur.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$connectionDB&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Connexion à la base de donées.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$countQuery&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// nombre de requêtes MySQL&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$fetch_row&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// mysql_fetch_row&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
* Constructeur de la classe&lt;br /&gt;
*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; DataBase&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt; ROOT_PATH.&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;conf_global.php&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_host'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;nbsp; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$CONF&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'DB_HOST'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_login'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;nbsp;= &lt;span style=&quot;color: #0000ff;&quot;&gt;$CONF&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'DB_LOGIN'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_pass'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;nbsp; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$CONF&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'DB_PASSWORD'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_name'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;nbsp; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$CONF&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'DB_NAME'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'debug_mod'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$CONF&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'DEBUG'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//####################################################################################################&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp;Fonctions de base du SGBD.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//####################################################################################################&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Connexion à la base de données&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; connect&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;connectionServer&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_connect&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_connect&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_host'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_login'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_pass'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or &lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;PortaLL ERROR: Cannot connect to mySQL server&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;connectionDB&lt;/span&gt; &amp;nbsp; &amp;nbsp; = &lt;a href=&quot;http://www.php.net/mysql_select_db&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_select_db&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_name'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;connectionServer&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or &lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;PortaLL ERROR: Cannot connect to database &amp;quot;&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'db_name'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Requête simple&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param (String) La requête à exécuter&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (String) La requête&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; query&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;query&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; or &lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;errorMsg&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Requête mySQL.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Débugage&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'debug_mod'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;countQuery&lt;/span&gt;++; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// +1 requêtes.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'debug_mod'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;listQuery&lt;/span&gt; .= &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;br /&amp;gt;&amp;lt;hr align=&amp;quot;center&amp;quot; /&amp;gt;'&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Ajoute les requète à la liste.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;query&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Fonction mysql_fetch_array&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param (String) La requête à exécuter&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (array) Résultat de la commande mysql_fetch_array&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; fetch_row&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/empty&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;empty&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fetch_row&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fetch_row&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fetch_row&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Fonction mysql_num_rows&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param (String) La requête à exécuter&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (int) Résultat de la commande mysql_num_rows&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; num_rows&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/empty&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;empty&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$num_rows&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_num_rows&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_num_rows&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$num_rows&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_num_rows&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_num_rows&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$num_rows&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//####################################################################################################&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp;Fonctions évoluées&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//####################################################################################################&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Compteur de requète (Debug mod &amp;gt; 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (int) Nombre de requêtes&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; countQuery&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;countQuery&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Liste des requêtes utilisées pour une page (Debug mod &amp;gt; 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (String) Liste des requêtes&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; listQuery&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;listQuery&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;listQuery&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;br /&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;b&amp;gt;&amp;lt;u&amp;gt;&amp;lt;font size=&amp;quot;+1&amp;quot;&amp;gt;Debug mySQL :&amp;lt;/font&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;listQuery&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Message d'erreur en cas de problème sur une requète mySQL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (String) Message d'erreur&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; errorMsg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$msg_error&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;font color=&amp;quot;#FF0000&amp;quot; size=&amp;quot;6&amp;quot;&amp;gt;&amp;lt;b&amp;gt;mySQL query error :&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;p&amp;gt; &amp;lt;/p&amp;gt;'&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$msg_error&lt;/span&gt; .= &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;mySQL error :&amp;lt;/b&amp;gt; '&lt;/span&gt;.&lt;a href=&quot;http://www.php.net/mysql_error&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_error&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;/p&amp;gt;'&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$msg_error&lt;/span&gt; .= &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;mySQL error code :&amp;lt;/b&amp;gt; '&lt;/span&gt;.&lt;a href=&quot;http://www.php.net/mysql_errno&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_errno&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;/p&amp;gt;'&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$msg_query&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$msg_error&lt;/span&gt; .= &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span style=&amp;quot;border: 1px solid #000000; width: 500px&amp;quot;&amp;gt;'&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$msg_query&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;/span&amp;gt;'&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; errorMsg;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Mise en forme du code mySQL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param (String) Liste des requêtes brute&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param (String) Séparateur de requêtes&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return (String) La liste des requêtes exécutées mise en forme&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; layout&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;br /&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt; == &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;br /&amp;gt;'&lt;/span&gt; || &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt; == &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;br /&amp;gt;'&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$tab&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;' &amp;nbsp; &amp;nbsp; '&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$tab&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;''&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#SELECT&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;(.+?)&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;FROM&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;SELECT&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;1'&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;FROM&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// SELECT xxx FROM&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#INSERT INTO&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;(.+?)&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;VALUES&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;INSERT INTO&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;1'&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;VALUES&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// INSERT xxx INTO&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#UPDATE&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;(.+?)&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;SET&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;UPDATE&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;1'&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;SET&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// UPDATE xxx SET&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#DELETE FROM&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;DELETE FROM&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// DELET FROM xxx&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;LEFT JOIN&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;(.+?)&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;ON&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$tab&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;LEFT JOIN&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; &lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;1 &amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;ON&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// LEFT JOIN xxx ON&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;WHERE&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WHERE &amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt;'&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// WHERE&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;ORDER BY&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;ORDER BY&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// ORDER BY&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;LIMIT&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #0000ff;&quot;&gt;$separator&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;span class=&amp;quot;debug_command&amp;quot;&amp;gt;&amp;lt;b&amp;gt;LIMIT&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// LIMIT&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/preg_replace&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;preg_replace&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'#&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;COUNT&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\(&lt;/span&gt;(.+?)&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\)&lt;/span&gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;AS&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\s&lt;/span&gt;#is'&lt;/span&gt; , &lt;span style=&quot;color: #ff0000;&quot;&gt;' &amp;lt;b&amp;gt;COUNT(&amp;lt;/b&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;1&amp;lt;b&amp;gt;) AS&amp;lt;/b&amp;gt; '&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* Déconnexion de la base de données&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* @author LLaumgui&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; close&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://www.php.net/mysql_close&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_close&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;connectionServer&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// EOC&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Ce qui donne avec le mod débug activé :&lt;/p&gt;
&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;http://www.llaumgui.com/public/images/web/debug_driver_mysql.png&quot;&gt;&lt;img src=&quot;http://www.llaumgui.com/public/images/web/.debug_driver_mysql_s.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;fieldset class=&quot;links&quot;&gt;&lt;legend&gt;Poursuivre l'aventure : &lt;/legend&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://llaumgui.com/post/php-base-de-donnees-et-couche-d39abstraction-1-principe&quot; hreflang=&quot;fr&quot;&gt;php, base de données et couche d'abstraction 1 (Principe)&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-2-compteur-de-requetes&quot; hreflang=&quot;fr&quot;&gt;php, base de données et couche d'abstraction 2 (Compteur de requêtes)&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;php, base de données et couche d'abstraction 3 (Driver MySQL).&lt;/li&gt;
&lt;/ul&gt;
&lt;/fieldset&gt;</description>
    
    
    
          <comments>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-1-driver-mysql#comment-form</comments>
      <wfw:comment>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-1-driver-mysql#comment-form</wfw:comment>
      <wfw:commentRss>http://www.llaumgui.com/feed/rss2/comments/16</wfw:commentRss>
      </item>
    
  <item>
    <title>php, base de données et couche d'abstraction 2 (Compteur de requêtes)</title>
    <link>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-2-compteur-de-requetes</link>
    <guid isPermaLink="false">urn:md5:5714171ee74200622479dfc9abc20f7c</guid>
    <pubDate>Tue, 18 Jan 2005 19:57:00 +0000</pubDate>
    <dc:creator>llaumgui</dc:creator>
        <category>Développement web</category>
        <category>MySQL</category><category>optimisation</category><category>php</category><category>SGBD</category>    
    <description>&lt;p&gt;Nous avons &lt;a href=&quot;http://www.llaumgui.com/post/php-base-de-donnees-et-couche-d39abstraction-1-principe&quot; title=&quot;fr&quot;&gt;Vu précédement&lt;/a&gt; le principe des couches d'abstraction dans la gestion des SGBD. Maintenant allons plus loin et réalisons un compteur de requêtes.&lt;/p&gt;    &lt;p&gt;Prenons l'exemple d'une base de donées MySQL. Si vous avez bien compris le principe de la couche d'abstraction, vous devez avoir une classe avec une fonction ressemblant à celle si :&lt;/p&gt;

&lt;code class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; database &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* [...]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* On passe la partie connexion à la base de données et définition des variables de la classe&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*(Notament Countquery qui doit être initialisé à 0).&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;* [..]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; query&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On réalise la requête MySQL&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;Query&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; or &lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;error_msg&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$query&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Compteur de requête :&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;Countquery&lt;/span&gt;++;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;Query&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;


&lt;p&gt;Nous avons donc établi un compteur de requête qui s'incrémente à chaque appel de la fonction &lt;em&gt;query()&lt;/em&gt;. Nous pouvons aller plus loin est stoker les requêtes dans un tableau afin de les afficher ultérieurement.&lt;/p&gt;

&lt;fieldset class=&quot;links&quot;&gt;&lt;legend&gt;Poursuivre l'aventure : &lt;/legend&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.llaumgui.com/post/php-base-de-donnees-et-couche-d39abstraction-1-principe&quot; hreflang=&quot;fr&quot;&gt;php, base de données et couche d'abstraction 1 (Principe)&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;php, base de données et couche d'abstraction 2 (Compteur de requêtes).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-1-driver-mysql&quot; hreflang=&quot;fr&quot;&gt;php, base de données et couche d'abstraction 3 (Driver MySQL)&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/fieldset&gt;</description>
    
    
    
          <comments>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-2-compteur-de-requetes#comment-form</comments>
      <wfw:comment>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-2-compteur-de-requetes#comment-form</wfw:comment>
      <wfw:commentRss>http://www.llaumgui.com/feed/rss2/comments/9</wfw:commentRss>
      </item>
    
  <item>
    <title>php, base de données et couche d'abstraction 1 (Principe)</title>
    <link>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-d39abstraction-1-principe</link>
    <guid isPermaLink="false">urn:md5:1e923194b112928e45dad7a1fd46dba4</guid>
    <pubDate>Wed, 12 Jan 2005 14:57:00 +0000</pubDate>
    <dc:creator>llaumgui</dc:creator>
        <category>Développement web</category>
        <category>MySQL</category><category>optimisation</category><category>php</category><category>SGBD</category>    
    <description>&lt;p&gt;Jusqu'a présent, le système de gestion de base de données (&lt;strong&gt;SGBD&lt;/strong&gt;) par excellence avec &lt;a href=&quot;http://www.php.net&quot; hreflang=&quot;US&quot;&gt;php&lt;/a&gt; était &lt;a href=&quot;http://www.mysql.com&quot; hreflang=&quot;US&quot;&gt;MySQL&lt;/a&gt;. L'arrivé de php5 et sa future démocratisation bouscule cette donne en mettant en avant le SGBD &lt;a href=&quot;http://www.sqlite.org/&quot; hreflang=&quot;US&quot;&gt;SQLite&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Comment passer le MySQL à SQLite facilement? Juste en modifiant une seule variable? C'est là qu'interviennent les &lt;strong&gt;couches d'abstraction&lt;/strong&gt;.&lt;/p&gt;    &lt;h2&gt;Qu'est ce qu'un couche d'abstraction?&lt;/h2&gt;
&lt;p&gt;De même que des drivers différents permettent l'utilisation d'une périphérie hardware à des systèmes différents; une couche d'abstraction permettra au même code php d'&lt;em&gt;attaquer&lt;/em&gt; des bases de données différentes.&lt;/p&gt;
&lt;h2&gt;Comment?&lt;/h2&gt;
&lt;p&gt;Tout simplement car le code n'&lt;em&gt;attaque&lt;/em&gt; pas la base de données mais la couche d'abstraction que nous appellerons &lt;strong&gt;drivers&lt;/strong&gt;.&lt;/p&gt;
&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;http://www.llaumgui.com/public/images/web/abstraction_php_sgbd.gif&quot; alt=&quot;Exemple de couche d'abstraction de SGBD&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Ainsi après avoir instancié les drivers adéquates (On peut passer par  une variable pour lancer cette instance ce qui permet de changer de drivers en modifiant une seule variable!!!) :&lt;/p&gt;
&lt;code class=&quot;php&quot;&gt;&lt;span style=&quot;color: rgb(255, 128, 0);&quot;&gt;// Récupération du drivers :
&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;require_once &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;ROOT_PATH&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 0, 0);&quot;&gt;&amp;quot;kernel/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;$CONF&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 0, 0);&quot;&gt;'DB_SGBD'&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 0, 0);&quot;&gt;&amp;quot;.php&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;;
&lt;br /&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 128, 0);&quot;&gt;// Instanciation :
&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;$DB             &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;= new &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;Database&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;();
&lt;br /&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 128, 0);&quot;&gt;// Connexion à la base de données :
&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;$DB&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;connect&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;
&lt;p&gt;Une requête ce fait alors de la sorte :&lt;/p&gt;
&lt;code class=&quot;php&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;
$DB&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 187);&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(221, 0, 0);&quot;&gt;&amp;quot;REQUETE&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 119, 0);&quot;&gt;)
&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;
&lt;p&gt;Pour changer de SGBD, il suffit alors de coder de nouveaux drivers et de changer une variable&lt;br /&gt;
L'utilisation de drivers prend légèrement plus de temps pour lancer le développement, mais les mises à jour sont bien plus aisées. Alors pourquoi s'en priver ?&lt;/p&gt;
&lt;p&gt;La prochaine étape et d'aller encore plus loin avec les couches d'abstraction en y introduisant des fonctions en plus comme celles de débugage par exemple.&lt;/p&gt;
&lt;fieldset class=&quot;links&quot;&gt;&lt;legend&gt;Poursuivre l'aventure : &lt;/legend&gt;&lt;ul&gt;
&lt;li&gt;php, base de données et couche d'abstraction 1 (Principe).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-2-compteur-de-requetes&quot; hreflang=&quot;fr&quot;&gt;php, base de données et couche d'abstraction 2 (Compteur de requêtes)&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.llaumgui.com/post/php-base-de-donnees-et-couche-dabstraction-1-driver-mysql&quot; hreflang=&quot;fr&quot;&gt;php, base de données et couche d'abstraction 3 (Driver MySQL)&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/fieldset&gt;</description>
    
    
    
          <comments>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-d39abstraction-1-principe#comment-form</comments>
      <wfw:comment>http://www.llaumgui.com/post/php-base-de-donnees-et-couche-d39abstraction-1-principe#comment-form</wfw:comment>
      <wfw:commentRss>http://www.llaumgui.com/feed/rss2/comments/8</wfw:commentRss>
      </item>
    
</channel>
</rss>