<?php
/**
* Autor: Vinicius Gallafrio - vgallafrio@madeinweb.com.br
* Date : 15/01/2002
* http://www.madeinweb.com.br
*
* Description: PHP Class for MySQL Connection
*/
// EXAMPLE FOR SELECT
include "class.mysql.php";
$mysql = New mysql('localhost','root','password','database',0);
$mysql->query("SELECT field FROM table"); /* ^-- change to 1 for debug mode */
if ($mysql->num_rows() > 0) {
while ($mysql->movenext()) {
echo $mysql->getfield("field");
}
}
// EXAMPLE FOR INSERT
include "class.mysql.php";
$mysql = New mysql('localhost','root','password','database',0);
$mysql->query("INSERT INTO table (field) values ('value')");
// EXAMPLE FOR UPDATE
include "class.mysql.php";
$mysql = New mysql('localhost','root','password','database',0);
$mysql->query("UPDATE table SET field='newvalue' WHERE fieldID=1");
// EXAMPLE FOR DELETE
include "class.mysql.php";
$mysql = New mysql('localhost','root','password','database',0);
$mysql->query("DELETE FROM table WHERE fieldID=1");
?>
|