Skip to content

jcguarinpenaranda/BDmanager-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

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 johny@company.com +011354987
2 Katherine katherine@company.com +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:"johny@company.com",
"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','jcguarinpenaranda@gmail.com','+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

About

Search easily in a Mysql database using PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages