Files
aportil/controller/libinterconn.php

216 lines
7.0 KiB
PHP

<?php
class LIBINTERCONN
{
var $inconn;var $dbcon;var $dbconORC;
public function __construct($CONNAME,$dbtype="mysql")
{
$this->inconn=array("HC"=>array("IP"=>"172.17.12.17","USER"=>"root","PASS"=>"p@ssw0rd2021","DB"=>"hrdwh_tcel"),
"MS"=>array("IP"=>"172.17.12.77","USER"=>"teldigthon","PASS"=>"teezdumk","DB"=>"redirector"),
"ANC"=>array("IP"=>"172.20.25.26/bonteng","USER"=>"crs","PASS"=>"tcel#crs","DB"=>"crs")
);
if($CONNAME)
{
if($dbtype=='mysql')
{
$this->dbcon=mysql_connect($this->inconn[$CONNAME]["IP"],$this->inconn[$CONNAME]["USER"],$this->inconn[$CONNAME]["PASS"],$this->inconn[$CONNAME]["DB"]);
mysql_select_db($this->inconn[$CONNAME]["DB"],$this->dbcon);
}
if($dbtype=='oci')
{
//$this->dbcon=oci_connect('crs', 'tcel#crs', '172.20.25.26/bonteng');
$this->dbconORC=oci_connect($this->inconn[$CONNAME]["USER"], $this->inconn[$CONNAME]["PASS"], $this->inconn[$CONNAME]["IP"]);
}
}
}
public function selectquery($query,$mysql_error=null)
{
$rsqry=@mysql_query($query,$this->dbcon);
if(!$mysql_error){$mysql_error=mysql_error();}
if(!$rsqry){echo $mysql_error;return false;}
return $rsqry;
}
public function selectqueryORC($query,$orc_error=null)
{
//echo $this->dbconORC." db";return false;
$rsqry=oci_parse($this->dbconORC,$query);
oci_execute($rsqry);
return $rsqry;
}
public function fn_row_isexists($query)
{
$rtn=false;
$rschk=$this->selectquery($query,$this->dbcon);
if($rschk)
{
if(mysql_num_rows($rschk)>0){$rtn=true;}
}
$this->clearrecordset($rschk);
return $rtn;
}
public function fn_row_isexistsORC($query)
{
$rtn=false;
$rschk=$this->selectqueryORC($query,$this->dbconORC);
if($rschk)
{
//if(mysql_num_rows($rschk)>0){$rtn=true;}
if(oci_num_rows($rschk)>0){$rtn=true;}
}
$this->clearrecordsetORC($rschk);
return $rtn;
}
public function data_row_object($recordset)
{
return mysql_fetch_object($recordset);
}
public function data_row_objectORC($recordset)
{
return oci_fetch_object($recordset);
}
public function data_row_array($recordset)
{
return mysql_fetch_array($recordset);
}
public function data_row_arrayORC($recordset)
{
return oci_fetch_array($recordset, OCI_BOTH+OCI_RETURN_NULLS);
}
public function field_length($recordset)
{
return mysql_num_fields($recordset);
}
public function field_lengthORC($recordset)
{
return oci_num_fields($recordset);
}
public function getErrorQuery()
{
return $this->errquery;
}
public function executequery($query)
{
if(mysql_query($query,$this->dbcon))
{return true;}
else
{$this->errquery=mysql_error(); die(mysql_error());return false;}
}
public function executequeryORC($query)
{
$rsqry=oci_parse($this->dbconORC,$query);
$res=oci_execute($rsqry);
if($res)
{oci_commit($this->dbconORC);return true;}
else
{$this->errquery=oci_error(); die(oci_error());return false;}
}
public function REC_ROWS_COUNT($recordset){return mysql_num_rows($recordset);}
public function REC_ROWS_COUNTORC($recordset){return oci_num_rows($recordset);}
public function fn_get_fieldvalue($fieldname,$query)
{
$rtn='';
$rsgetvalue=mysql_query($query,$this->dbcon) or die(mysql_error());
if($rsgetvalue)
{
if(mysql_num_rows($rsgetvalue)>0)
{
$rw=mysql_fetch_object($rsgetvalue);
$rtn=$rw->$fieldname;
}
}
$this->clearrecordset($rsgetvalue);
return $rtn;
}
public function fn_get_fieldvalueORC($fieldname,$query)
{
$rtn='';
$rsgetvalue=$this->selectqueryORC($query,$this->dbconORC);
if($rsgetvalue)
{
//if(mysql_num_rows($rschk)>0){$rtn=true;}
if(oci_num_rows($rsgetvalue)>0)
{
$rw=oci_fetch_object($rsgetvalue);
$rtn=$rw->$fieldname;
}
}
$this->clearrecordsetORC($rsgetvalue);
return $rtn;
}
public function fn_get_fieldsvalues($fieldsname,$query)
{
$rtn='';
$spfields=explode(",",trim($fieldsname));
$rsgetvalue=$this->selectquery($query,$this->dbcon);
if($rsgetvalue)
{
if(mysql_num_rows($rsgetvalue)>0)
{
$rw=mysql_fetch_object($rsgetvalue);
for($i=0;$i<=count($spfields)-1;$i++)
{
$rtn.=$rw->$spfields[$i]."|";
}
$rtn=substr($rtn,0,strlen($rtn)-1);
}
}
$this->clearrecordset($rsgetvalue);
$rtn=explode("|",$rtn);
return $rtn;
}
public function fn_get_fieldsvaluesORC($fieldsname,$query)
{
$rtn='';
$spfields=explode(",",trim($fieldsname));
$rsgetvalue=$this->selectquery($query,$this->dbconORC);
if($rsgetvalue)
{
if(oci_num_rows($rsgetvalue)>0)
{
$rw=oci_fetch_object($rsgetvalue);
for($i=0;$i<=count($spfields)-1;$i++)
{
$rtn.=$rw->$spfields[$i]."|";
}
$rtn=substr($rtn,0,strlen($rtn)-1);
}
}
$this->clearrecordsetORC($rsgetvalue);
$rtn=explode("|",$rtn);
return $rtn;
}
public function clearrecordset($recordset)
{
if($recordset){mysql_free_result($recordset);}
}
public function clearrecordsetORC($recordset)
{
if($recordset){oci_free_statement($recordset);}
}
}
?>