-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This is only a short wiki on how to use the Phine framework
Use this code to create database objects
require_once <Path/To/Framework/>_Package.php';
use Phine\Framework\Database\ObjectGeneration;
use Phine\Framework\Database\Mysqli\Connection;
$connection = new Connection('<db_host>', '<db_user>', '<db_password>', '<db_name>');
$mapper = new ObjectGeneration\CamelCaseTableNameMapper('Phine\Projects\MyProject\Database');
$generator = new ObjectGeneration\TableObjectGenerator($connection, PHINE_PATH . 'Projects/MyProject/Database', $mapper);
$generator->Generate();
This will add the database objects in a subdirectory of the folder where the framework resides. This subdirectory is named Projects/MyProject/Database. Not that PHINE_PATH is the parent folder of the framework.
The objects will be pushed into the namespace Phine\Projects\MyProject\Database. You can, of course, use any other disc location and namespace.
Here is how to create, read, update and delete a database object
use Phine\Projects\MyProject\Database as DB;
//Create:
$user = new DB\User();
$user->SetEMail('user@this-domain-doesnt-exi.st');
$user->Save();
//Get user with id 1 and update:
$user = new DB\User(1);
$user->SetEMail('webmaster@this-domain-doesnt-exi.st');
$user->Save();
//Read data from user
$email = $user->GetEMail();
//Delete user
$user->Delete();