You are not logged In.
LOGINREGISTER
FORGET PASSWORD
About
Documentation
Download
Older Releases
  • This database plugin is very nice and allows you to do many things. Some highlights of what it can do:
    Class /Model/mymodel.php: <?php
    class mymodel extends model
    {
        public function 
    __construct()
        {
            
    parent::__construct();
            
    $this->loadPlugin("database");
            
    $database = new database($this->getLink());

            
    // Run a regular query (with binding / escaping)
            
    $arrayInsert = array("1","aziz","hussain");
            
    $sql "INSERT INTO users (id,fname,lname) VALUES (?,?,?)";
            
    $database->mysqlQuery($sql,$arrayInsert);

            
    // Print our all users
            
    print_r($database->result("SELECT * FROM users"));

            
    // Get primary key field of a table
            
    echo $database->getPrimaryField("users");

            
    // Delete function (overloaded in 3 ways)

            // Delete record with primary key 1
            
    $database->delete("users","1");

            
    // Delete record with specific field
            
    $database->delete("users","fname","aziz");

            
    // Delete a record based on multiple fieldnames
            
    $database->delete("users",array("fname" => "aziz""lname" => "hussain"));

            
    // Update user record
            
    $data = array("id" => 1"fname" => "aziz""lname" => "hussain");
            
    $database->insert("users",$data);

            
    // Add new record (leave primary key empty)
            
    $data = array("fname" => "aziz""lname" => "hussain");
            
    $database->insert("users",$data);

            
    // Let's say that I did not have the above table created, to create it simply
            
    $data = array("id" => 1"fname" => "aziz""lname" => "hussain");
            
    $database->createTable($data,"users");
        }
    ?>
© Aziz S. Hussain 2009, except where otherwise stated
Contact Me - My Resume & Portfolio - Privacy Policy - TOS