Aziz Saleh – Software development

  • Home
  • Downloads
    • AzizMVC Downloads
      • Database Plugin
        • Template Plugin
    • Flash Builder 4
      • Bypass, Hijack, Beat, and Defeat Same Origin Policy
      • Flash Click Tracker
      • Flash Link Hider
      • Pacman source V 1.0
    • Java Downloads
      • Currency Converter
    • Javascript Downloads
    • PHP/MySQL Downloads
      • Aziz MVC
      • AzizMVC Documentation
      • Contact Form Maker
      • NetFlix API 1.0 Wrapper
      • Simple Blog
    • Visual Basic Downloads
      • Currency Converter
        • Key Logger w/Store, email, registry options
  • Resume & Portfolio
  • Ask me a question
  • Contact Me

Database Plugin

Usage Example:

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");
    }
}

Installation:

  • Extract the file into your /Plugin folder.
  • Load the plugin where you like.

System Requirements:

  • PHP 4/PHP 5

Related Videos:

 

 

 

 

 

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • PHP does not have MySQL support enabled.
  • Your PHP installation appears to be missing the MySQL extension which is required by WordPress
  • Undefined mysql functions (mysql_connect, mysql_select_db, mysql_query) – PDO alternative
  • Checking if you have Javascript installed by PHP
  • Process Maxmind countries, regions and cities – Parser to MySQL or SqLite

Recent Comments

  • fathima on Currency Converter Using Java Netbeans
  • Chris on Currency Converter
  • Khalid Ahmad Qweder on Resume & Portfolio
  • Michel on Currency Converter
  • Michel on Currency Converter

Archives

  • March 2014
  • September 2013
  • November 2012
  • October 2012
  • November 2011
  • February 2011
  • December 2010
  • November 2010
  • August 2010
  • May 2010
  • September 2009

Categories

  • Flash Builder 4
  • General
  • Java
  • Javascript
  • MySQL
  • PHP
  • Visual Basic

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
CyberChimps ©2023