3
How to import data from Firebird for Mysql using the PHP
?
3
How to import data from Firebird for Mysql using the PHP
?
3
The answer below had originally been posted as a question by the author of the question. Now set as a Community Wiki to register.
A while ago I had the need to import the data from a table of Firebird to another table in mysql, at the time I did not find anything ready that met the needs so I researched and mounted the code below.
<?php
set_time_limit(0);//zera o limite de tempo
//conexão com mysql
$mysql=mysql_connect('localhost','root','root');
//conexão com firebird
$ibase=ibase_connect('C:\RAAS.GDB', 'SYSDBA', 'masterkey') or die ('Erro ao conectar');
$i=0;
$busca=ibase_query("SELECT CD_COD, CD_DESCR FROM S_CID",$ibase);
$count=ibase_fetch_object($busca);
$total=count($busca);
while($row=ibase_fetch_object($busca)){
//dentro da query o nome raas.cid10 são banco de dados e tabela
$sql =mysql_query("insert into raas.cid10 (codigo, descricao) values ('".$row->CD_COD."', '".substr($row->CD_DESCR,5,100)."') ",$mysql);
$i++;
$largura=(($i*100)/$total);//calcula andamento da operação em percentual
$perc=(int)($largura);
echo "<div style='width:300px; height:20px; background:#fff; border:1px solid #f00; position:absolute; top:55px; left:10px'>
<div style='width:$largura%; height:20px; background:#f00; position:absolute; top:0; left:0'></div>
</div>
<div style='width:100px; height:20px; background:#fff; position:absolute; top:95px; left:155px'>$perc</div>
";
}
if($sql){
echo $i."registros importados";
}
?>
Browser other questions tagged php mysql firebird
You are not signed in. Login or sign up in order to post.
This question was closed as "too wide" without the author having a chance to post his answer (which had originally been posted in the question area; the author was to arrange according to my guidance). So I reopened and posted his reply. I don’t see how too wide, considering the short answer below.
– bfavaretto