Skip to content

blacktoko/PDO-Databaseclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDO Database class

Simpel class for PDO beginners. The basic PDO features are Available in this class.

Setup Config

Fill the yaml file as the config example. ```yaml name: database_host: localhost database_name: dbname database_user: root database_password: password ``` The name is the handle name to call the connection.

Setup

* Run composer update to fetch the yaml class. * include the vendor/autoload.php in your php file.

New php classes and files

When you extend this project in your own. Update the psr-4 piece in the composer.json file. After updating and giving the namespaces run ```composer dump-autoload``` to update the autoloader files.

Create connection

```php $database = new Database('handlename'); ``` The connection is setup according to the handle name given with the variables in the config file.

Select one line from database

```php $query = 'SELECT * FROM `table` WHERE `name`=:name LIMIT 1';

$database->query($query); $database->bind(':name', 'John');

$objects = $database->single();


<h2>Select multiple lines from database</h2>
```php
$query = 'SELECT * FROM `table`';

$database->query($query);
$objects = $database->resultset();

Insert into database

```php $query = ' INSERT INTO `table` (`name`, `age`) VALUES (:name, :age)'; $database->query($query); $database->bind(':name', 'John'); $database->bind(':age', 28); $database->execute(); ```

About

Simple PDO Database class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages