
17/05/2002, 03:41
|
| | Fecha de Ingreso: abril-2002
Mensajes: 23
Antigüedad: 23 años Puntos: 0 | |
Re: Clase para acceder a BBDD function select ($sql= "")
{
if (empty($sql)) { return false;}
if (!eregi("^select",$sql))
{
echo "<h2>Error in command</h2><br>\n";
}
if (empty($this->Conn)) { return false;}
$conn = $this->Conn;
$results = mysql_query($sql,$conn);
echo Mysql_error();
if ((!$results) or (empty($results)) )
{
mysql_free_result($results);
return false;
}
$count = 0;
$data = array();
// First element in array contains the num of selected rows
$data[0] = mysql_num_rows($results);
while ($row = mysql_fetch_array($results))
{
$data[$count+1] = $row;
$count++;
}
mysql_free_result($results);
return $data;
} //End function select
function insert ($sql= "")
{
if (empty($sql)) { return false;}
if (!eregi("^insert",$sql))
{
echo "<h2>Error in command</h2><br> \n";
}
if (empty($this->Conn)) { return false;}
$conn = $this->Conn;
$results = mysql_query($sql,$conn);
echo $mysql_error;
if (!$results) { return false;}
$results = mysql_insert_id();
return $results;
} //End function insert
function update ($sql= "")
{
if (empty($sql)) { return false;}
if (!eregi("^update",$sql))
{
echo "<h2>Error in command</h2><br> \n";
}
if (empty($this->Conn)) { return false;}
$conn = $this->Conn;
$results = mysql_query($sql,$conn);
if (!$results) { return false;}
$results = mysql_insert_id();
return $results;
} //End function update
function delete ($sql= "")
{
if (empty($sql)) { return false;}
if (!eregi("^delete",$sql))
{
echo "<h2>Error in command</h2><br> \n";
}
if (empty($this->Conn)) { return false;}
$conn = $this->Conn;
$results = mysql_query($sql,$conn);
if (!$results) { return false;}
return $results;
} //End function delete |