<?php
ini_set
(
'disply_error'
, E_ALL);
$fb_host
=
'localhost:база'
;
$fb_username
=
'SYSDBA'
;
$fb_password
=
'пароль'
;
$mysql_host
=
'localhost'
;
$mysql_username
=
'root'
;
$mysql_password
=
'пароль'
;
$mysql_db
=
'база'
;
$dbh
= ibase_connect (
$fb_host
,
$fb_username
,
$fb_password
)
or
die
(
"Firebird умер"
);
$dbm
= mysql_connect (
$mysql_host
,
$mysql_username
,
$mysql_password
)
or
die
(
"MySQL умерла"
);
$tr
= ibase_trans (IBASE_NOWAIT, IBASE_READ, IBASE_CONCURRENCY,
$dbh
);
mysql_select_db(
$mysql_db
);
mysql_query(
"SET NAMES 'cp1251'"
);
$stmt
=
'select count(*) from my_tbl'
;
$sth
= ibase_query(
$dbh
,
$stmt
);
while
(
$row
= ibase_fetch_assoc(
$sth
))
{
$count
=
intval
(
$row
[
'COUNT'
]) ;
}
$mincnt
=0;
$stmt
=
'select max(key) from my_tbl'
;
$sth
= ibase_query(
$dbh
,
$stmt
);
while
(
$row
= ibase_fetch_assoc(
$sth
))
{
$maxcnt
=
intval
(
$row
[
'MAX'
]);
}
$cnt
=
$mincnt
;
$rcnt
=0;
$rcnts
=0;
while
(
$rcnts
<
$count
)
{
$stmt
=
'select count(*) from my_tbl where key BETWEEN ('
.
$cnt
.
') AND ('
.(
$cnt
+49999).
') '
;
$sth
= ibase_query(
$tr
,
$stmt
);
while
(
$row
= ibase_fetch_assoc(
$sth
))
{
$rcnt
=
intval
(
$row
[
'COUNT'
]);
}
$stmt
=
'SELECT * FROM my_tbl WHERE key BETWEEN ('
.
$cnt
.
') AND ('
.(
$cnt
+49999).
') ORDER BY key'
;