Skip to content

This code helps you to make a simple database using .txt file and provide you will all necessary functionalities to create, modify a database

License

Notifications You must be signed in to change notification settings

stanliwise/Text-driven-database-using-PHP-OOP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text-driven-database-using-PHP-OOP

This code helps you to make a simple database using .txt file and provide you will all necessary functionalities to create, modify a database

To make use of this simple PHP Functionalities; enusre your have "src" folder simply include 'src/DBFactory.php' into your script; Also ensure you create a valid folder which would represent your Database Repo, For example a folder 'StanDatabase' would represent the name of a database

To get the Database instance use the database facade

    //Case is insensitive
    $database = DBFactory::get('StanDatabase'); 
    $database->new_table('unique_table_name', $columns[], 'unique_column');

Note: Set the complete path of directory from Config.php, default value is __DIR__ constant. This means your complete your path for DBFactory::get() will be __DIR__ . 'StanDatabase'

Alternatively can you set global path to where your database folder would be found.

Example:

    //this set path to find your database folders
    DBFactory::set_gloabal_path($path_to_database_folder); 
This means if you refer to your database e.g 'StanDatabase' It means your complete path would be 
    $path_to_database_folder . '/StanDatabase'

METHOD DATABASE OBJECT

  1. To create new table in the database, use
    $database->new_table('unique_table_name', $columns[], 'unique_column');
  1. To delete a table from your database
 $database->delete_table($table_name);
The code return true if succesful and returns false if unsuccesful
  1. To get a Table instance

    $user = $database->get_table($table_name);
  2. To see the current database folder/path

    //this is if you know a user id
    $user = $database->getPath(); 
  1. For 3 to 4, if retrieval was succesful the you can get user data from the variable
    $user->getId(); //returns a user id
    $user->getPassword(); //returns a user password
    $user->getEmail(); //returns a user email
    $user->getUsername(); //returns a user username;
b. To change a user password

```php
$user->changePassword('new_password'); //changes the user password
```

For any questions whatApp me @ 08172833073

About

This code helps you to make a simple database using .txt file and provide you will all necessary functionalities to create, modify a database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages