Skip to content
agentmedia edited this page Jan 30, 2014 · 6 revisions

This is only a short wiki on how to use the Phine framework

ORM

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.

Using Database objects

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();

Clone this wiki locally