Giter Site home page Giter Site logo

php-mysqli-class's Introduction

PHP-Mysqli-Class

Simple Mysqli Library for PHP

| id | user_name |    user_email    |
------------------------------------
| 1  | John Doe  | [email protected]  |
| 2  | Jen Doe   | [email protected]   |
| 3  | Junior Doe| [email protected]|

#Usage

This class has query,table,update,delete and insert methods to easily usage. First we need to configure our database connection.

require("mysqli.class.php");
$config['db_host']      = "localhost";
$config['db_username']  = "root";
$config['db_password']  = "password";
$config['db_name']      = "testdb";

$db = new db();

thats it.

###Inserting Data This method gets two parameters. First is "table name", second is our data in array. @param Array Data

$db->insert("users", 
array("user_name" => "John Doe",
      "user_email" => "[email protected]")
      );

###Update This method gets three parameters. First is "table name", second is our data in array and third is "where situation"

$db->update("users", 
array("user_name" => "Jen Doe",
      "user_email" => "[email protected]),
array("id" => "1");

###Delete

$db->delete("users",
array("id" => "1"));

Important : If you dont set second param, this method drops your table!

###List Table This method returns array object.

 $users =  $db->table("SELECT * FROM users);
 
 foreach($users as $user){
    echo $user->user_name;
 }

###List One Row This method list one row by your query.

$user = $db->row("SELECT * FROM users WHERE id=1);

echo $user->user_name;
//output
John Doe

###Field

$count = $db->field("SELECT COUNT(id) FROM users);
echo $count;
//output
3

Easy? huh.

php-mysqli-class's People

Contributors

bencagri avatar

Stargazers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.