<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.cubrid.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.cubrid-prepare.php',
    1 => 'cubrid_prepare',
    2 => 'Pr&eacute;pare une requ&ecirc;te SQL pour son ex&eacute;cution',
  ),
  'up' => 
  array (
    0 => 'ref.cubrid.php',
    1 => 'Fonctions CUBRID',
  ),
  'prev' => 
  array (
    0 => 'function.cubrid-pconnect-with-url.php',
    1 => 'cubrid_pconnect_with_url',
  ),
  'next' => 
  array (
    0 => 'function.cubrid-put.php',
    1 => 'cubrid_put',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/cubrid/functions/cubrid-prepare.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.cubrid-prepare" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">cubrid_prepare</h1>
  <p class="verinfo">(PECL CUBRID &gt;= 8.3.0)</p><p class="refpurpose"><span class="refname">cubrid_prepare</span> &mdash; <span class="dc-title">Prépare une requête SQL pour son exécution</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.cubrid-prepare-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>cubrid_prepare</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$conn_identifier</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$prepare_stmt</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$option</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></div>

  <p class="simpara">
   La fonction <span class="function"><strong>cubrid_prepare()</strong></span> prépare une requête SQL pour un
   gestionnaire de connexion fourni. Cette requête SQL pré-compilée sera incluse dans
   la fonction <span class="function"><strong>cubrid_prepare()</strong></span>.
  </p>
  <p class="simpara">
   De plus, il est possible d&#039;utiliser cette requête à plusieurs reprises ou pour traiter
   de gros volumes de données. Une seule requête peut être utilisée et il est possible d&#039;y
   placer des variables. L&#039;ajout d&#039;une variable se fait lorsque l&#039;on veut
   lier une valeur dans la clause VALUES ou WHERE d&#039;une requête. Il est à noter qu&#039;il est
   autorisé de lier une valeur à une variable (?) uniquement en utilisant la fonction
   <span class="function"><a href="function.cubrid-bind.php" class="function">cubrid_bind()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.cubrid-prepare-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">conn_identifier</code></dt>
    <dd><span class="simpara">Identifiant de connexion.</span></dd>
   
   
    <dt><code class="parameter">prepare_stmt</code></dt>
    <dd><span class="simpara">Requête préparée.</span></dd>
   
   
    <dt><code class="parameter">option</code></dt>
    <dd><span class="simpara">OID retourné par l&#039;option <strong><code>CUBRID_INCLUDE_OID</code></strong>.</span></dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.cubrid-prepare-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Identifiant de requête en cas de succès, ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.cubrid-prepare-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 Exemple avec <span class="function"><strong>cubrid_prepare()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">, </span><span style="color: #0000BB">33000</span><span style="color: #007700">, </span><span style="color: #DD0000">"demodb"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$sql </span><span style="color: #007700">= &lt;&lt;&lt;EOD<br /></span><span style="color: #DD0000">SELECT g.event_code, e.name<br />FROM game g<br />JOIN event e ON g.event_code=e.code<br />WHERE host_year = ? AND event_code NOT IN (SELECT event_code FROM game WHERE host_year=?) GROUP BY event_code;<br /></span><span style="color: #007700">EOD;<br /><br /></span><span style="color: #0000BB">$req </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cubrid_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2004</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">2000</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$row_num </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"There are %d event that exits in 2004 olympic but not in 2000. For example:\n\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$row_num</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-15s %s\n"</span><span style="color: #007700">, </span><span style="color: #DD0000">"Event_code"</span><span style="color: #007700">, </span><span style="color: #DD0000">"Event_name"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"----------------------------\n"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-15d %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">"event_code"</span><span style="color: #007700">], </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">"name"</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">cubrid_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-15d %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">"event_code"</span><span style="color: #007700">], </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">"name"</span><span style="color: #007700">]);<br /><br /></span><span style="color: #0000BB">cubrid_disconnect</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">There are 27 event that exits in 2004 olympic but not in 2000. For example:

Event_code      Event_name
----------------------------
20063           +91kg
20070           64kg</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.cubrid-prepare-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.cubrid-execute.php" class="function" rel="rdfs-seeAlso">cubrid_execute()</a> - Ex&eacute;cute une requ&ecirc;te SQL pr&eacute;par&eacute;e</span></li>
   <li><span class="function"><a href="function.cubrid-bind.php" class="function" rel="rdfs-seeAlso">cubrid_bind()</a> - Lie des valeurs &agrave; une requ&ecirc;te pr&eacute;par&eacute;e</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>