PHP code example of miladm / orm

1. Go to this page and download the library: Download miladm/orm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

miladm / orm example snippets


use miladm\table\Table;

class User extends Table {

}

class User extends Table {
	public function connection() {
		return new MainConnection;
	}

	public function tableName() {
		return 'user';
	}
}

	public function init()
	{
		$this->leftJoin( .... );
	}

use miladm\table\Connection;

class MainConnection extends Connection
{
    public $host = "127.0.0.1";
    public $databaseName = "sample";
    public $user = 'root';
    public $password = 'root';
}

class User extends Table {
	...

	public function connection() {
		return new MainConnection;
	}

	....
}

    public function key()
    {
        return 'id';
	}

$userTable = new user;
$userTable->select();// this will select all records from user table

// equal Query : SELECT * FROM `user` WHERE 1

$UserModel = new User();
$userData = $userModel->where(['id' => 1])->select();
echo $userData[0]->name; // its alex for example
$userData[0]->name = 'jack'; // variable updated but not saved on database
$userData[0]->save(); // now the change has updated the database