PHP Classes

File: testdata.php

Recommend this page to a friend!
  Classes of Alexander Serbe   xMySQL   testdata.php   Download  
File: testdata.php
Role: Auxiliary script
Content type: text/plain
Description: Creates a table and inserts some test data.
Class: xMySQL
Simple but effective class for the work with MySQL
Author: By
Last change: I have replaced the testdata.sql with a php file that will do the job. So you won't have to bother where to run the sql script in...
Date: 21 years ago
Size: 1,393 bytes
 

Contents

Class file image Download
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Unbenannt</title>
</head>

<body>

<?php
if ( file_exists ( "objectstatus.class.php" ) )
    include (
"objectstatus.class.php" );
include (
"xmysql.class.php" );

if (
class_exists ( "objectStatus" ) )
   
$os = new objectStatus ();
else
   
$os = "";

$db = new xMySQL ( "xmysql.host_list.php", 0, &$os );

// Step 1: Create the table
$query = "create table if not exists xmysql_test ( test_id int (10) unsigned default '1' not null auto_increment, test_field_1 varchar (255) not null, test_field_2 varchar (255) not null, test_field_3 int (10) unsigned default 0 not null, test_field_4 decimal (6,2) unsigned default 0.00 not null, primary key test_id(test_id)) type=MYISAM;";

$x = $db->xQuery ( $query );



// Step 2: Insert some data
if ( $x )
{
   
$y = 0;
    for (
$i=1; $i<10; $i++ )
    {
       
$query = "insert into xmysql_test (test_field_1, test_field_2, test_field_3, test_field_4) values (\"Test $i\", \"Blub\", $i, " . ($i/2) . ");";
       
$y = $db->xQuery ( $query );
    }
}

if (
$x && $y )
{
    echo
"<b>Queries executed...</b>";
    if (
class_exists ( "objectStatus" ) )
        echo
$db->os->statusPrintout ();
}
else
{
    if (
class_exists ( "objectStatus" ) )
        echo
$db->os->statusPrintout ();
    else
        echo
"<b>Failed executing queries...</b>";
}
?>

</body>
</html>