Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 1.91 KB

README.md

File metadata and controls

111 lines (80 loc) · 1.91 KB

BDmanager-PHP

Search easily in a Mysql database using PHP

What does it do?

It takes out some of the pain of playing with mysql in PHP, letting you write less code and go faster!

Usage

First you have to include or require the class BDManager

include 'path/to/BDManager.php';

Now you have to set the host, username, password and database you want to use.

include 'path/to/BDManager.php';

$bd = new BDManager('localhost','root','','your-database-name');

And you are good to go!

#Examples

Given the following table called 'users' in MySql, we are going to make a SELECT, UPDATE, DELETE.

id name email telephone
1 Johny [email protected] +011354987
2 Katherine [email protected] +011324786
  1. Select * from users, and then echo all their names
$users = $bd->query('select * from users');

for($i=0; $i<count($users); $i++){
  echo $users[$i]['name'];
}
  1. If you want to connect your results as a Web Service, you could just simply do:
$users = $bd->query('select * from users');

header('Content-Type: application/json');
echo json_encode($users);

you would get:

[
{
"id":1,
"name":"Johny",
"email:"[email protected]",
"telephone":"+011354987"
},
{
.... other results
}
]
  1. Insert a user, and verify if it was done
$bool = $bd->insert("insert into users (id,name,email,telephone) values (3,'Juan','[email protected]','+57351684886')");

if($bool){
  //do something
}else{
  //throw error or whatever
}

.... more examples coming soon!

#License Use BDManager as you want. You can modify it, distribute it, use it for commercial purposes .. well you name it.

By Juan Camilo Guarin Peñaranda http://otherwise-studios.com