Question

I'm working with a database making several inserts/updates and the process is very slow.

In the process of trying to fix it I found ibase_prepare and ibase_execute and now I'm working on a function to make all the updates and inserts with it.

The problem comes with the number of fields to insert/update, they are variable and I don't know how to make the call to ibase_execute($query, $field1, $field2,..., $fieldx);

Sometimes is 1, others 2, others more.

<?php
$dbh = ibase_connect($host, $username, $password);
$updates = array(1 => 'Eric',5 => 'Filip',7 => 'Larry');
$query = ibase_prepare($dbh, "UPDATE FOO SET BAR = ? WHERE BAZ = ?");
foreach ($updates as $baz => $bar) {
    ibase_execute($query, $bar, $baz);
}
?>

Any idea to work with? Is possible to define a function in execution time? on a stream or something like that?

Thanks for your time

Was it helpful?

Solution

call_user_func_array should be able to do what you want. Just put your fields into an array:

$result = call_user_func_array("ibase_execute", array("field1"); //Just 1 field
$result = call_user_func_array("ibase_execute", array("field1", "field2", "field3")); //3 fields
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top