PHP Classes

File: cmysql_mset.class.inc

Recommend this page to a friend!
  Classes of markitos   cmysql_mset   cmysql_mset.class.inc   Download  
File: cmysql_mset.class.inc
Role: ???
Content type: text/plain
Description: Mysql class
Class: cmysql_mset
Author: By
Last change:
Date: 23 years ago
Size: 4,063 bytes
 

Contents

Class file image Download
<? #:::::::::::::::::::::::::::::::::::::::::::::# #: Nombre Clase....: CMySQL_MSet :# #: Autor...........: mArkitos :# #: Fecha...........: 23/10/2000 :# #: Contacto........: markitos@office.com :# #:...........................................:# # U.Modificacion..: 03/01/2001 :# #:::::::::::::::::::::::::::::::::::::::::::::# class CMySQL_MSet { var $DB_Name; var $DB_User; var $DB_Pass; var $DB_Host; var $DB_Link; var $CM_TRUE = 1; var $CM_FALSE = 0; Function CMySQL_MSet ($Nombre_DB, $User_DB, $Pass_DB, $Host_DB){ $this->DB_Name = $Nombre_DB; $this->DB_User = $User_DB; $this->DB_Pass = $Pass_DB; $this->DB_Host = $Host_DB; return $this->CM_TRUE; } Function OpenConnection(){ $this->DB_Link = mysql_connect ("$this->DB_Host", "$this->DB_User", "$this->DB_Pass"); if (!$this->DB_Link){ return $this->CM_FALSE; } else { mysql_select_db ($this->DB_Name); } return $this -> CM_TRUE; } Function CloseConnection(){ if ($this->DB_Link){ mysql_close ($this->DB_Link); } return $this -> CM_TRUE; } Function ExecSQL ($Sql){ if (($Sql == '') || (strlen ($Sql)< 10) || (!$Sql)){ return $this->CM_FALSE; } $State = mysql_query ("$Sql", $this->DB_Link); unset ($Sql); return $State; } Function SearchIn ($NombreTabla, $NombreCampo, $Patron, $Completa){ if ((strlen ($Patron)<1) || $Patron == ''){ return $this->CM_FALSE; } $Resultado = mysql_list_tables ($this->DB_Name, $this->DB_Link); $Contador = 0; while ($Contador < mysql_num_rows ($Resultado)) { $Nombre_Tabla[$Contador] = mysql_tablename ($Resultado, $Contador); if ($Nombre_Tabla[$Contador] == $NombreTabla){ $Existe = 1; } $Contador++; } if (! isset ($Existe)){ return $this->CM_FALSE; } else { unset ($Exite); unset ($Contador); unset ($Nombre_Tabla); $SQL = "SELECT "; $SQL .= $NombreCampo; $SQL .= " FROM "; $SQL .= $NombreTabla; $Resultado = mysql_query ("$SQL"); while ($QuItems = mysql_fetch_row ($Resultado)){ if ($Completa == 1){ if (eregi ("^$Patron$", $QuItems[1])){ $Founds[] = $QuItems[0]; } } else { if (eregi ("$Patron", $QuItems[1])){ $Founds[] = $QuItems[0]; } } } unset ($Completa); unset ($Resultado); unset ($SQL); return $Founds; } } Function SearchAdv ($NombreTabla, $NombreCampo, $Patron, $Completa, $Is_CaseS, $Condicion_Is, $Condicion){ if ((strlen ($Patron)<1) || $Patron == ''){ return $this->CM_FALSE; } $Resultado = mysql_list_tables ($this->DB_Name, $this->DB_Link); $Contador = 0; while ($Contador < mysql_num_rows ($Resultado)) { $Nombre_Tabla[$Contador] = mysql_tablename ($Resultado, $Contador); if ($Nombre_Tabla[$Contador] == $NombreTabla){ $Existe = 1; } $Contador++; } if (! isset ($Existe)){ return $this->CM_FALSE; } else { unset ($Exite); unset ($Contador); unset ($Nombre_Tabla); $SQL = "SELECT "; $SQL .= $NombreCampo; $SQL .= " FROM "; $SQL .= $NombreTabla; if ($Condicion_Is == 1){ $SQL .= " "; $SQL .= $Condicion; unset ($Condicion_Is); unset ($Condicion); } $Resultado = mysql_query ("$SQL"); while ($QuItems = mysql_fetch_row ($Resultado)){ if ($Completa == 1){ if ($Is_CaseS == 1){ if ($Patron == $QuItems[1]){ $Founds[] = $QuItems[0]; } } else { if (eregi ("^$Patron$", $QuItems[1])){ $Founds[] = $QuItems[0]; } } } else { if ($Is_CaseS == 1){ if (ereg ("$Patron", $QuItems[1])){ $Founds[] = $QuItems[0]; } } else { if (eregi ("$Patron", $QuItems[1])){ $Founds[] = $QuItems[0]; } } } } unset ($Is_CaseS); unset ($Resultado); unset ($SQL); return $Founds; } } }?>