1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <?php
mysql_connect("localhost","root","");
mysql_select_db("USER");
$sql=mysql_query("DELETE test");;
mysql_close();
include("connexion.php");
$output = ob_get_contents();
$stmt = OCIParse($connexion, "SELECT a.sbs_no, a.sbs_name, b.store_no, b.store_name
FROM subsidiary_v a, store_v b
where a.sbs_no = b.sbs_no
and b.sbs_no > 0
and b.store_no > 0
and b.store_no < 200
order by a.sbs_no, b.store_no");
OCIExecute($stmt);
$nrows = oci_fetch_all($stmt, $res);
echo "$nrows rows fetched<br>\n";
echo'<pre>';
var_dump($res);
echo'</pre>';
include("deconnexion.php");
mysql_connect("localhost","root","*****");
mysql_select_db("USER");
$SQL = 'INSERT INTO test (sbs_no,sbs_name, store_no, store_name) VALUES';
foreach ($res as $sbs_no=>$sbs_name=>store_no=>store_name) {
$SQL .= '('.mysql_real_escape_string($sbs_no).',\''.mysql_real_escape_string($sbs_name).'\''.mysql_real_escape_string($store_no).'\''.mysql_real_escape_string($store_name).'\'),';
}
//$SQL = substr($SQL,0,-1).';';
var_dump($SQL); // ça c'est juste pour voir le résultat
?> |
Partager