ibase_execute

(PHP 5, PHP 7 < 7.4.0)

ibase_executeEjecutar una consulta previamente preparada

Descripción

ibase_execute(resource $query, mixed $bind_arg = ?, mixed $... = ?): resource

Ejecuta una consulta preparada por ibase_prepare().

Este mecanismo es mucho más eficiento que el uso de ibase_query() si repite el mismo tipo de consulta varias veces sólamente modificando ciertos parámetros.

Parámetros

query

Una consulta InterBase preparada por ibase_prepare().

bind_arg

...

Valores devueltos

Si la consulta genera un error, se devuelve false. Si tiene éxito y existe un conjunto de resultados (posiblemente vacío), tal como ocurre con una consulta SELECT, se devuelve el identificador de resultado. Si la consulta fue exitosa y no hay resultados, se devuelve true.

Nota:

Esta función devuelve el número de filas afectadas por la consulta (si es > 0 y aplicable al tipo de sentencia). Una consulta que haya tenido éxito, pero no afectó fila alguna (p.ej. una operación UPDATE sobre un registro inexistente) devolverá true.

Ejemplos

Ejemplo #1 Ejemplo de ibase_execute()

<?php

$dbh 
ibase_connect($host$nombre_usuario$contrasenya);

$cambios = array(
    
=> 'Eric',
    
=> 'Filip',
    
=> 'Larry'
);

$consulta ibase_prepare($dbh"UPDATE FOO SET BAR = ? WHERE BAZ = ?");

foreach (
$cambios as $baz => $bar) {
    
ibase_execute($consulta$bar$baz);
}

?>

Ver también

  • ibase_query() - Ejecutar una consulta en una base de datos InterBase

add a note add a note

User Contributed Notes 2 notes

up
2
mclap at ulstu dot ru
21 years ago
For variable argument list in ibase_execute you can use folowing functions:

For PHP >= 4.0.4:

function db_execute($stmt,$data)
{
    if(!is_array($data))
        return ibase_execute($stmt,$data);
    array_unshift($data,$stmt);
    $rc=call_user_func_array('ibase_execute',$data);
    return $rc;
}

For any version of PHP:
function db_execute($stmt,$data)
{
    if(!is_array($data))
        return ibase_execute($stmt,$data);

    $params = array();
    while( list($k,$v) = each($data) )
        $params[$k] = '$data['.$k.']';
    eval('$rc=ibase_execute($stmt,'.join(',',$params).');');

    return $rc;
}
up
0
caveman
21 years ago
ibase_execute only return resource id not the actual result, you need to use ibase_fetch_row or ibase_fetch_object to retrieve actual result.

On the example above given by anthony
it should be like these

$dbh = ibase_connect ( $host, $username, $password ) ;
$stmt = 'SELECT * FROM "EMPLOYEE" WHERE "SALARY" = ? AND "DEPT_CD" = ? ;' ;
$prep = ibase_prepare ( $dbh, $stmt ) ;

$salary = Array ( "10000", "25000", "33000", "48000" ) ;
$dept_cd = 'SALES' ;

foreach ( $salary as $val ) {
   $res = ibase_execute ($prep, $val, $dept_cd);
   $taxForm[$val] = ibase_fetch_row ($res);
}
To Top