Hello all,
I am working on a project where I am doing an ETL of data from a Firebird database, using the iBase functions of PHP.
I'm doing this:
$dbh = ibase_connect($host, $dbuser, $dbpass);
$fbquery="some really complex query";
$p_sql = ibase_prepare($fbquery);
$fbresult = ibase_execute($p_sql);
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
while($fbrow = ibase_fetch_assoc($fbresult)){
$insert="INSERT INTO table (fields) VALUES ('";
$foo=0;
foreach($fbrow as $fbvalue) {
if ($foo==1) { $insert.=", "; }
$insert.= "'" . $fbvalue . "'";
$foo=1;
}
$insert.=")";
echo ".";
if ($conn->query($insert) === TRUE) {$c++;}
}
echo $c . " records added. <br />";
Which should put all results from the ibase query into a mysql table, transformed into a format where I can use for my application.
My issue is that when I run the initial query directly against the firebird database (using dbvisualizer), I get 147450 records. If I use ODBC and pull this same query into an Excel file, I get the same number of results.
However, when my loop runs, I'm only getting 142516 records. Somehow, I'm losing 4900ish records.
I've looked for an ibase_count function, but the only thing I've found is ibase_affected_rows, which doesn't apply to select statements.
Am I making some stupid error, or is something else wrong?
Any help would be greatly appreciated!