2017 © Pedro Peláez
 

library orm

image

pavlyshyn/orm

  • Friday, August 5, 2016
  • by pavlyshyn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

use Pavlyshyn\Orm;
use Pavlyshyn\DB\Driver\MySQL;
use Model\User;

$orm = new Orm(new MySQL('localhost', 'test_orm', 'root', 'password'));

OR 

use Pavlyshyn\DB\Driver\MongoDB;
$orm = new Orm(new MongoDB('localhost', 'test_orm'));
<?php

namespace Model;

use \Pavlyshyn\Model;

/**
 * @tableName users
 */
class User extends Model {

    protected $id;
    protected $name;
    protected $mail;
    protected $password;

    public function setId($id) {
        return $this->id = $id;
    }

    public function getId() {
        return $this->id;
    }

    public function setName($name) {
        return $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }

    public function setMail($mail) {
        return $this->mail = $mail;
    }

    public function getMail() {
        return $this->mail;
    }

    public function setPassword($password) {
        return $this->password = $password;
    }

    public function getPassword() {
        return $this->password;
    }

}
INSERT
$user = new User();
$user->name = 'Username';
$user->mail = 'username@mail.com';
$user->password = sha1('password');
$orm->save($user);
UPDATE
//get user
$user = new User();
$user->id = 1;
$user = $orm->get($user);

//update
$user->password = sha1('new password');
$orm->save($user);
GET
$users = new User();
$tabUsers = $orm->getAll($users);

var_dump($tabUsers);

foreach($tabUsers as $user){
    echo 'Name : ' . $user->name . '<br>';
    echo 'Email : ' . $user->mail . '<br>';
    echo 'Password : ' . $user->password . '<br>';
}
DELETE BY ID
$users = new User();
$user->id = 1;
$orm->deleteById($users);
DELETE (PARAMETERS $OBJECT, $ROWNAME AND $VALUE)
$users = new User();
$orm->delete($users, 'name', 'Username');
COUNT
$users = new User();
$count = $orm->count($users);
var_dump($count);
EXIST (PARAMETERS $OBJECT, $ROWNAME AND $VALUE)
$users = new User();
$res = $orm->exist($users, 'name', 'Username');
var_dump($res);

The Versions

05/08 2016

dev-master

9999999-dev

  Sources   Download

GNU

The Requires

 

22/07 2016

0.2.4

0.2.4.0

  Sources   Download

GNU

The Requires

 

20/07 2016

0.2.3

0.2.3.0

  Sources   Download

GNU

The Requires

 

20/07 2016

0.2.2

0.2.2.0

  Sources   Download

GNU

The Requires

 

17/07 2016

0.2.1

0.2.1.0

  Sources   Download

GNU

The Requires