The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other [Free Resource] Php MySQL Class 1.3

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #27894

    I have create a simple Class for connecting, and sending queries to your MySQL database through php. There are already a set of functions for creating a connection to a MySQL Database and sending Queries of course, this just makes it a bit easier. Below is a list of functions for the class, and an example script from one of my web applications.

    *Note: PHP file below.

    [Version 1.3]
    [Added] SelectDatabase( $db)
    [Added] TableCreate( $name, $column_array )
    [Added] TableInsert( $name, $column_array, $values_array)

    Class Variables:
    $host – This host name for the SQL Connection, Defaults to localhost.
    $database – This is the name of the Database that will be accessed.
    $username – This is the username for the user accessing the database.
    $password – This is the password for the user.
    $connection – This is the variable when the SQL connection is stored.
    $silent – This Determines if the class will echo debug information for it’s functions.

    IsSilent( $bool ) – This function sets the silent variable.
    Status( $message ) – This is a mainly internal function to display status messages. Only works if $silent is set to false.
    SetHost( $hostname ) – This will set the $host variable.
    SetDatabase( $db ) – Sets the Database to be used.
    SetUsername( $user ) – Sets the Username that will be used.
    SetPassword( $pass ) – Sets the Password that will be used.
    Connect() – Connects to the SQL Server with provided information.
    Query() – Attempts to run a Query on the SQL Server, returns the result.
    Close() – Closes the Current SQL Connection.
    SelectDatabase( $db ) – Sets the Database, Variable and Selects it.
    TableCreate( $name, $column_array ) – Creates a New Table.
    TableInsert( $name, $column_array, $values_array) – Inserts Data into a Table.

    TODO: SelectTable( $name ) – Selects a Table.
    TODO: DropTable( $name ) – Drops a Table.


    SetDatabase( ‘yourdatabasenamehere’ );
    $sql->SetUsername( ‘yourusernamehere’ );
    $sql->SetPassword( ‘yourpasswordhere’ );

    $sql->IsSilent( false );


    $columnsA = Array( ‘id INT PRIMARY KEY AUTO_INCREMENT’ , ‘username VARCHAR(255)’ , ‘password VARCHAR(255)’ );
    $columnsB = Array( ‘username’ , ‘password’ );
    $valuesA = Array( ‘”Anthoni”‘ , ‘”TestPass”‘ );
    $valuesB = Array( ‘”Mark”‘ , ‘”Whalberg”‘ );

    $sql->TableCreate( ‘tbl_test’, $columnsA );
    $sql->TableInsert( ‘tbl_test’, $columnsB, $valuesA );
    $sql->TableInsert( ‘tbl_test’, $columnsB, $valuesb );



    Example Script on PasteAll:

    Get the Script Here:

    If you have any comments, questions, or bugs please post them below. Thanks!


    No Problem. This is the first time I have actually though about releasing my scripts. Maybe I will start releasing more. :)


    Looks very usefull :), thanks for sharing!


    wow, took me a little to figure out this that and the other, but this.. it’s simply amazing. I love it.. thank you very much.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.