<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.uodbc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.odbc-execute.php',
    1 => 'odbc_execute',
    2 => 'Ejecuta una consulta SQL preparada',
  ),
  'up' => 
  array (
    0 => 'ref.uodbc.php',
    1 => 'Funciones ODBC',
  ),
  'prev' => 
  array (
    0 => 'function.odbc-exec.php',
    1 => 'odbc_exec',
  ),
  'next' => 
  array (
    0 => 'function.odbc-fetch-array.php',
    1 => 'odbc_fetch_array',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/uodbc/functions/odbc-execute.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.odbc-execute" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_execute</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">odbc_execute</span> &mdash; <span class="dc-title">Ejecuta una consulta SQL preparada</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.odbc-execute-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_execute</strong></span>(<span class="methodparam"><span class="type">Odbc\Result</span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$params</code><span class="initializer"> = []</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Ejecuta una consulta SQL preparada por <span class="function"><a href="function.odbc-prepare.php" class="function">odbc_prepare()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.odbc-execute-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">statement</code></dt>
     <dd>
      <p class="para">
       El objeto de resultado ODBC desde <span class="function"><a href="function.odbc-prepare.php" class="function">odbc_prepare()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">params</code></dt>
     <dd>
      <p class="para">
       Los valores del parámetro <code class="parameter">params</code> serán
       sustituidos en las variables de consulta de la consulta preparada.
       Los elementos de este array serán convertidos a string al
       llamar a esta función.
      </p>
      <p class="para">
       Todo parámetro de <code class="parameter">params</code> que
       comience y termine con comillas simples será considerado
       como un nombre de fichero a leer y enviado a la base de datos,
       con la variable de consulta apropiada.
      </p>
      <span class="simpara">
       Si se desea almacenar un string que comience y termine
       realmente con comillas, se debe añadir un espacio al inicio
       o al final del string, para evitar que este parámetro sea confundido con
       un nombre de fichero. Si esto no es posible en el contexto de la aplicación,
       se deberá utilizar la función <span class="function"><a href="function.odbc-exec.php" class="function">odbc_exec()</a></span>.
      </span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.odbc-execute-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Esta función retorna <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en caso de éxito o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si ocurre un error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.odbc-execute-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.4.0</td>
 <td>
  Esta función ahora devuelve una instancia de
  <span class="classname"><strong class="classname">Odbc\Result</strong></span>; anteriormente, se devolvía un <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       El parámetro <code class="parameter">flags</code>, sin uso, ha sido eliminado.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.odbc-execute-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 
     Ejemplo con <span class="function"><strong>odbc_execute()</strong></span> y
     <span class="function"><a href="function.odbc-prepare.php" class="function">odbc_prepare()</a></span>
    </strong></p>
    <div class="example-contents"><p>
     En el script siguiente, <var class="varname">$success</var> solo será
     posible si los tres parámetros de myproc
     son parámetros de tipo IN:
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">3</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt    </span><span style="color: #007700">= </span><span style="color: #0000BB">odbc_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'CALL myproc(?,?,?)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$success </span><span style="color: #007700">= </span><span style="color: #0000BB">odbc_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, array(</span><span style="color: #0000BB">$a</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</span><span style="color: #007700">, </span><span style="color: #0000BB">$c</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   Si se necesita llamar a un procedimiento almacenado utilizando parámetros
   INOUT o OUT, la solución es utilizar una extensión nativa de la base de datos
   (por ejemplo <a href="ref.oci8.php" class="link">oci8</a> para Oracle).
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.odbc-execute-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.odbc-prepare.php" class="function" rel="rdfs-seeAlso">odbc_prepare()</a> - Prepara una orden para su ejecuci&oacute;n</span></li>
   </ul>
   </p>
  </div>


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