<?php
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
//
$s="SELECT * FROM xginterna WHERE id_gi<=212651 AND id_gi>0 ORDER BY id_gi LIMIT 0, 10000";
$rs=grs($s);
while($r=$rs->fetch_assoc()){
	$KOD=$r['id_gi'];
	$CX=gn("count(*)","ginterna","id_gi=".$KOD);
	$BX=gn("count(*)","ginterna_det","id_gi=".$KOD);
	if($CX>0 && $BX>0){
		//
		ejt("DELETE FROM ginterna_det WHERE id_gi=".$KOD);
		/*
		$s="INSERT INTO ginterna SELECT * FROM xginterna WHERE id_gi=".$KOD;
		ejt($s);
		echo $s."<br>";
		*/
		$s="INSERT INTO ginterna_det SELECT * FROM xginterna_det WHERE id_gi=".$KOD;
		ejt($s);
		echo $s."<br>";
		$s="UPDATE xginterna SET id_gi=id_gi * -1 WHERE id_gi=".$KOD;
		ejt($s);
	}else{
		echo "ERROR : ".$KOD."<br>";
	}
	
}
echo "FINAL KOD : ".$KOD;
//
?>