Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

MySQL-Example

Sections:

Example Code

The following code demonstrates how to use the class.

<?php
/*!***********************************************************************
 *************************************************************************
 * \file            mysql-sample.php
 *
 * \author          Kai Klenovsek
 *
 * \date            First Step: 2004-12-22
 *
 * \note <br>
 * \b THE \bBEER-WARE \bLICENSE <br>
 *    As long as you retain this notice you can do whatever you want with <br>
 *    this stuff. If we meet some day, and you think this stuff is worth it, <br>
 *    you can buy me a beer in return. <br>
 *
 * \b NOTES: <br>
 *
***************************************************************************
***************************************************************************/

// First we have to include the phplibex 
require("../../phplibex.inc.php");
    
// Lets create an object $dbase from class mysql.
$dbase = new mysql;
  
// Connect to the database and check it.
if ( $dbase->sql_connect( "localhost", "root" , "", "test" ) )
{
    // Drop the Table if exist.
    $sql = "DROP TABLE TestTable";
    $result = $dbase->sql_query( $sql );    
    
    // Create the table
    $sql = "CREATE TABLE TestTable (ID BIGINT NOT NULL ,SureName TEXT NOT NULL ,LastName TEXT NOT NULL )";
    $dbase->sql_query( $sql );

    $dbase->sql_close();
  
    echo "Everything works fine.<br>";
}
else
    echo "OhOh sorry, Error occurred<br><br>";

// Get the error list
$errorlist = $dbase->sql_get_errorlist();
    
if ( sizeof($errorlist) >= 1 )
{
    echo "<b>Error messages:</b><br>";
    
    // Show error strings
    for ( $loop=0; $loop <= sizeof($errorlist); $loop++ )
        echo "<b>".$errorlist[$loop]."</b><br>";
}       

?>

Related links:

MYSQL: http://www.mysql.com
Generated on Fri Aug 26 08:13:54 2005 for PHP-Lib-Xtreme by  doxygen 1.4.3