ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
§´§à§Ý§ã§ä§Ñ§ñ §Þ§à§Õ§Ö§Ý§î
       §ª§ã§ä§à§â§Ú§ñ §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ORM

§º§Ñ§Þ§Ú§ß §®§Ú§ç§Ñ§Ú§Ý
Geometria.ru
§£§Ö§Õ§å§ë§Ú§Û §â§Ñ§Ù§â§Ñ§Ò§à§ä§é§Ú§Ü
§´§à§Ý§ã§ä§Ñ§ñ §Þ§à§Õ§Ö§Ý§î. §ª§ã§ä§à§â§Ú§ñ §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ORM
Geometria.ru

? §¤§Ý§Ñ§Ó§ß§í§Û §æ§à§ä§à§ç§â§à§ß§Ú§Ü§Ö§â §ã§ä§â§Ñ§ß§í
? 8 §Ý§Ö§ä §ß§Ñ §â§í§ß§Ü§Ö
? §±§â§Ö§Õ§ã§ä§Ñ§Ó§Ú§ä§Ö§Ý§î§ã§ä§Ó§à §Ó 150 §Ô§à§â§à§Õ§Ñ§ç §²§à§ã§ã§Ú§Ú, §³§¯§¤ §Ú
  §±§â§Ú§Ò§Ñ§Ý§ä§Ú§Ü§Ú
? §¦§Ø§Ö§Õ§ß§Ö§Ó§ß§à 80 000 §á§à§Ý§î§Ù§à§Ó§Ñ§ä§Ö§Ý§Ö§Û / 600 000 §á§â§à§ã§Þ§à§ä§â§à§Ó
? §£ §á§à§ß§Ö§Õ§Ö§Ý§î§ß§Ú§Ü 110 000 / 1 000 000
? §¢§à§Ý§Ö§Ö 500 000 §â§Ö§á§à§â§ä§Ñ§Ø§Ö§Û
? 15 000 000 §æ§à§ä§à§Ô§â§Ñ§æ§Ú§Û
? 800 000 §Ù§Ñ§â§Ö§Ô§Ú§ã§ä§â§Ú§â§à§Ó§Ñ§ß§ß§í§ç §á§à§Ý§î§Ù§à§Ó§Ñ§ä§Ö§Ý§Ö§Û
§´§à§Ý§ã§ä§Ñ§ñ §Þ§à§Õ§Ö§Ý§î. §ª§ã§ä§à§â§Ú§ñ §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ORM
§±§à§é§Ö§Þ§å §á§à§ß§Ñ§Õ§à§Ò§Ú§Ý§ã§ñ §ã§Ó§à§Û ORM

§¢§í§Ý§à

?   §¯§Ñ§ã§Ý§Ö§Õ§ã§ä§Ó§à §Ó §Ó§Ú§Õ§Ö §Ù§Ñ§Ý§Ö§Ø§Ö§Û §Ü§à§Õ§Ñ-§Ý§Ñ§á§ê§Ú
?   §±§â§Ñ§Ü§ä§Ú§é§Ö§ã§Ü§Ú §Ó§ã§ñ §Ò§Ú§Ù§ß§Ö§ã-§Ý§à§Ô§Ú§Ü§Ñ §Ó §Ü§à§ß§ä§â§à§Ý§Ý§Ö§â§Ñ§ç
?   §£§á§Ý§à§ä§î §Õ§à §æ§à§â§Þ§Ú§â§à§Ó§Ñ§ß§Ú§ñ select §à§Ó!
?   §¯§Ö§Ü§à§ä§à§â§í§Ö §ï§Ü§ê§Ö§ß§í §â§Ñ§Ù§Þ§Ö§â§à§Þ §Ó 200 §ã§ä§â§à§Ü!
?   §£ §â§à§Ý§Ú §Þ§à§Õ§Ö§Ý§Ú - Zend_Db_Table
§±§à§é§Ö§Þ§å §á§à§ß§Ñ§Õ§à§Ò§Ú§Ý§ã§ñ §ã§Ó§à§Û ORM

§³§ä§Ñ§Ý§à

? §³§ä§Ñ§Ý§Ú §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î NoSQL §â§Ö§ê§Ö§ß§Ú§ñ, §ä§Ñ§Ü§Ú§Ö §Ü§Ñ§Ü Redis §Ú
  Mongo
? §±§à§ß§Ñ§Õ§à§Ò§Ú§Ý§à§ã§î §â§Ö§ê§Ö§ß§Ú§Ö, §Ô§à§ä§à§Ó§à§Ö §â§Ñ§Ò§à§ä§Ñ§ä§î §ã §Ý§ð§Ò§í§Þ
  §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö§Þ, §Ñ §ß§Ö §ä§à§Ý§î§Ü§à SQL
? §¦§ã§ä§î §Ý§Ú §é§ä§à-§ä§à §ß§Ñ §â§í§ß§Ü§Ö?
? Doctrine2 §Ó alph§Ñ, §Ö§ë§Ö §ã§í§â§Ñ§ñ - §ã§ä§â§Ñ§ê§ß§à.
? §¹§ä§à §Õ§Ö§Ý§Ñ§ä§î?
? §±§Ú§ê§Ö§Þ §ã§Ó§à§Û §Ó§Ö§Ý§à§ã§Ú§á§Ö§Õ!
§£§í§Ò§à§â §Õ§Ú§Ù§Ñ§Û§ß§Ñ



                 §°§ä§Ü§â§í§Ó§Ñ§Ö§Þ §Ü§ß§Ú§Ô§å

              §®§Ñ§â§ä§Ú§ß§Ñ §¶§Ñ§å§Ý§Ö§â§Ñ
                   (Martin Fowler)

"§º§Ñ§Ò§Ý§à§ß§í §Ü§à§â§á§à§â§Ñ§ä§Ú§Ó§ß§í§ç §á§â§Ú§Ý§à§Ø§Ö§ß§Ú§Û"
  ("Patterns of Enterprise Application Architecture")
§´§à§Ý§ã§ä§Ñ§ñ §Þ§à§Õ§Ö§Ý§î. §ª§ã§ä§à§â§Ú§ñ §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ORM
§£§í§Ò§à§â §Õ§Ú§Ù§Ñ§Û§ß§Ñ

         §ª §ß§Ñ§ç§à§Õ§Ú§Þ §ä§à §é§ä§à §ß§å§Ø§ß§à.

           Domain Model
                  §Ú§Ý§Ú
     §®§à§Õ§Ö§Ý§î §á§â§Ö§Õ§Þ§Ö§ä§ß§à§Û §à§Ò§Ý§Ñ§ã§ä§Ú
§±§à§Ý§ñ §Þ§à§Õ§Ö§Ý§Ú. §¬§Ñ§Ü §Ù§Ñ§Õ§Ñ§Ó§Ñ§ä§î ?

? §£ Zend_Db_Table_Row §á§à§Ý§ñ §ß§Ö §á§â§à§á§Ú§ã§Ñ§ß§í §ñ§Ó§ß§à, §Ñ
  §Ò§Ö§â§å§ä§ã§ñ §Ú§Ù §ã§ç§Ö§Þ§í §ä§Ñ§Ò§Ý§Ú§è§í §¢§¥

? §£ Doctrine2 §é§Ö§â§Ö§Ù §Ù§Ñ§Õ§Ñ§ß§Ú§Ö private/protected §ã§Ó§à§Û§ã§ä§Ó §Ú
  §Ô§Ö§ß§Ö§â§Ñ§è§Ú§ð getter/setter §Þ§Ö§ä§à§Õ§à§Ó.
§±§à§Ý§ñ §Þ§à§Õ§Ö§Ý§Ú. §²§Ö§ê§Ö§ß§Ú§Ö:

§ª§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î DocBlock
§±§â§à§æ§Ú§ä§í:

?   §¤§à§ä§à§Ó§í§Û §ê§Ñ§Ò§Ý§à§ß §Õ§Ý§ñ §ä§Ú§á§à§Ó §Õ§Ñ§ß§ß§í§ç
?   §³§â§Ñ§Ù§å §Ó §Ñ§ß§ß§à§ä§Ñ§è§Ú§Ú §Ü§Ý§Ñ§ã§ã§Ñ §Ó§Ú§Õ§ß§í §Ó§ã§Ö §á§à§Ý§ñ §Þ§à§Õ§Ö§Ý§Ú
?   §¡§Ó§ä§à§Ü§à§Þ§á§Ý§Ú§ä §Ó IDE (Zend Studio, PhpStorm, NetBeans)
?   §¢§í§ã§ä§â§à§Ö §ã§à§Ù§Õ§Ñ§ß§Ú§Ö §Ü§Ý§Ñ§ã§ã§à§Ó
Zend_Reflection §Õ§Ý§ñ §Ô§Ö§ß§Ö§â§Ñ§è§Ú§Ú §á§à§Ý§Ö§Û

/**
  * @property integer $id
  * @property string $title
  * @property string $body
  * @property boolean $hidden
  * @property integer $date
  **/
class Model_Post extends Geometria_Model
{
}
Zend_Reflection §Õ§Ý§ñ §Ô§Ö§ß§Ö§â§Ñ§è§Ú§Ú §á§à§Ý§Ö§Û
§±§à§ã§Ý§Ö $post = new Model_Post();

§ã§Ó§à§Û§ã§ä§Ó§à $_data §Ò§å§Õ§Ö§ä §Ó§í§Ô§Ý§ñ§Õ§Ö§ä§î §ã§Ý§Ö§Õ§å§ð§ë§Ú§Þ §à§Ò§â§Ñ§Ù§à§Þ:

class Model_Post extends Geometria_Model
{
    protected $_data = array(
        'id' => null,
        'title' => null,
        'body' => null,
        'hidden' => null,
        'date' => null,
    );
}
§¥§à§ã§ä§å§á §Ü §á§à§Ý§ñ§Þ

? §£§ß§Ö§ê§ß§Ú§Û §Õ§à§ã§ä§å§á §Ü §á§à§Ý§ñ§Þ §à§Ò§Ö§ã§á§Ö§é§Ú§Ó§Ñ§Ö§ä§ã§ñ §é§Ö§â§Ö§Ù
  §Þ§Ñ§Ô§Ú§é§Ö§ã§Ü§Ú§Ö §Þ§Ö§ä§à§Õ§í __get() §Ú __set()

? §®§à§Ø§ß§à §â§Ö§Ñ§Ý§Ú§Ù§à§Ó§Ñ§ä§î §Þ§Ö§ä§à§Õ§í get<§á§à§Ý§Ö> §Ú set<§á§à§Ý§Ö>,
  §é§ä§à§Ò§í §Ú§Ù§Þ§Ö§ß§Ú§ä§î §Ý§à§Ô§Ú§Ü§å §å§ã§ä§Ñ§ß§à§Ó§Ü§Ú/§á§à§Ý§å§é§Ö§ß§Ú§ñ §Ù§ß§Ñ§é§Ö§ß§Ú§ñ
  §á§à§Ý§ñ.
/**
  * ...
  * @property integer $date Unix timestamp
  */
class Model_Post extends Geometria_Model
...
public function setDate($value)
{
     if ($value instanceof Zend_Date) {
         $value = $value->getTimestamp();
     }
     $this->_data['date'] = $value;
}
§µ§ã§ä§Ñ§ß§à§Ó§Ü§Ñ §Ù§ß§Ñ§é§Ö§ß§Ú§ñ §á§à §å§Þ§à§Ý§é§Ñ§ß§Ú§ð

class Model_Post extends Geometria_Model
...
public function getDate($value)
{
    if (null === $this->_data['date']) {
        $this->_data['date'] = time();
    }
    return $this->_data['date'];
}
§¬§Ñ§Ü §ç§â§Ñ§ß§Ú§ä§î §Þ§à§Õ§Ö§Ý§î?

§ª§ã§á§à§Ý§î§Ù§å§Ö§Þ DataMapper

? §®§Ñ§á§á§Ö§â §Ù§ß§Ñ§Ö§ä §Ó§ã§Ö §à §Þ§à§Õ§Ö§Ý§Ú §Ú §à §ä§à§Þ, §Ü§Ñ§Ü §Ú §Ô§Õ§Ö §Ö?
  §ç§â§Ñ§ß§Ú§ä§î.
? §®§à§Õ§Ö§Ý§î §ß§Ú§é§Ö§Ô§à §ß§Ö §Ù§ß§Ñ§Ö§ä §à §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö.
? §­§à§Ô§Ú§Ü§Ñ §Õ§à§Þ§Ö§ß§Ñ §à§ä§Õ§Ö§Ý§Ö§ß§Ñ §à§ä persist §Ý§à§Ô§Ú§Ü§Ú
? §®§à§Ø§ß§à §Þ§Ö§ß§ñ§ä§î §ã§ä§â§å§Ü§ä§å§â§å §Ò§Õ §Ú§Ý§Ú §Õ§Ñ§Ø§Ö §ã§Þ§Ö§ß§Ú§ä§î
  §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö, §ß§Ö §Þ§Ö§ß§ñ§ñ §Ý§à§Ô§Ú§Ü§å §Þ§à§Õ§Ö§Ý§Ú, §Ó§ã§Ö§Ô§à §Ý§Ú§ê§î
  §Ú§Ù§Þ§Ö§ß§Ú§Ó §Þ§Ñ§á§á§Ö§â.
? §®§Ñ§á§á§Ö§â §Ó§í§á§à§Ý§ß§ñ§Ö§ä CRUD §à§á§Ö§â§Ñ§è§Ú§Ú
? §®§à§Ø§ß§à §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î §Ý§ð§Ò§à§Ö §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö: MySQL, Mongo,
  Redis, Config file, RESTApi §Ú §Õ§â.
§ª§ß§ä§Ö§â§æ§Ö§Û§ã §Þ§Ñ§á§á§Ö§â§Ñ

interface Geometria_Model_Mapper_Interface
{
    public function create(Geometria_Model $model);

    public function update(Geometria_Model $model);

    public function delete(Geometria_Model $model);

    public function fetchOne($cond, $sort);

    public function fetchAll($cond, $sort, $limit, $skip);

    public function getCount($cond);
}
§²§Ñ§Ò§à§ä§Ñ §ã §Þ§à§Õ§Ö§Ý§î§ð

$post = new Model_Post();
$post->title = 'hello world!';
$post->body = 'foo bar';

$postMapper = new Model_Post_Mapper();
$postMapper->create($post);

echo $post->id; // 1 §Þ§Ñ§á§á§Ö§â §ã§Ñ§Þ §á§â§à§ã§ä§Ñ§Ó§Ú§Ý §Ó §Þ§à§Õ§Ö§Ý§Ú
id
§£§í§Ò§à§â§Ü§Ú
? §µ§ã§Ý§à§Ó§Ú§Ö $cond - §á§â§à§ã§ä§à§Û §Þ§Ñ§ã§ã§Ú§Ó
  §Ú§Þ§ñ §á§à§Ý§ñ => §Ù§ß§Ñ§é§Ö§ß§Ú§Ö
? §³§à§â§ä§Ú§â§à§Ó§Ü§Ñ $sort - §ä§à§Ø§Ö §á§â§à§ã§ä§à §Þ§Ñ§ã§ã§Ú§Ó
  §Ú§Þ§ñ §á§à§Ý§ñ => (bool) §ß§Ñ§á§â§Ñ§Ó§Ý§Ö§ß§Ú§Ö §ã§à§â§ä§Ú§â§à§Ó§Ü§Ú
? §¥§Ý§ñ §Ò§à§Ý§Ö§Ö §ã§Ý§à§Ø§ß§í§ç §Ó§í§Ò§à§â§à§Ü §á§Ú§ê§Ö§Þ §à§ä§Õ§Ö§Ý§î§ß§í§Û §Þ§Ö§ä§à§Õ

§£§í§Ò§â§Ñ§ä§î 10 §ã§Ü§â§í§ä§í§ç §á§à§ã§ä§à§Ó, §ß§Ñ§é§Ú§ß§Ñ§ñ §ã §ã§Ñ§Þ§í§ç §ß§à§Ó§í§ç

$mapper->fetchAll(
    array('hidden' => true),
    array('date' => false),
    10
);
§¥§Ö§Ý§Ñ§Ö§Þ ActiveRecord

§²§Ñ§ã§ã§Ü§Ñ§Ù§í§Ó§Ñ§Ö§Þ §Þ§à§Õ§Ö§Ý§Ú, §é§ä§à §å §ß§Ö§Ö §Ö§ã§ä§î §Þ§Ñ§á§á§Ö§â.

? §¥§Ö§Ý§Ñ§Ö§Þ §ã§ä§Ñ§ä§Ú§é§Ö§ã§Ü§Ú§Û §Þ§Ö§ä§à§Õ getMapper() §Ü§à§ä§à§â§í§Û §Ú§Ù
  §ã§á§Ö§è§Ú§Ñ§Ý§î§ß§à§Ô§à §Ü§à§ß§ä§Ö§Û§ß§Ö§â§Ñ
  Geometria_Model_Mapper_Manager §Õ§à§ã§ä§Ñ§Ö§ä §ß§å§Ø§ß§í§Û §Ö§Û
  §Þ§Ñ§á§á§Ö§â
? §¥§Ö§Ý§Ñ§Ö§Þ §å §Þ§à§Õ§Ö§Ý§Ú §Þ§Ö§ä§à§Õ§í create(), update(), delete()


public function create()
{
    return self::getMapper()->create($this);
}
§´§Ö§á§Ö§â§î §ã§à§Ù§Õ§Ñ§ß§Ú§Ö §Þ§à§Õ§Ö§Ý§Ú §Ó§í§Ô§Ý§ñ§Õ§Ú§ä §ä§Ñ§Ü:
$post = new Model_Post();
$post->title = 'hello world!';
$post->body = 'foo bar';
$post->create();

echo $post->id; // 1

§¡ §á§à§ã§ä §Þ§à§Ø§ß§à §á§à§Ý§å§é§Ú§ä§î §Ó §à§Õ§ß§å §ã§ä§â§à§é§Ü§å:

$post = Model_Post::getMapper()->fetchOne(
    array('id' => 1)
);
§Ú§Ý§Ú §ä§Ñ§Ü
$post = Model_Post::getMapper()->fetch(1);
§¹§ä§à §Ó§Ö§â§ß§Ö§ä fetchAll()? §¬§à§Ý§Ý§Ö§Ü§è§Ú§ð!

? §Ñ§ß§Ñ§Ý§à§Ô Zend_Db_Table_Rowset
? §±§Ñ§ä§ä§Ö§â§ß Record Set
? §±§à§Ù§Ó§à§Ý§ñ§Ö§ä §Ó§í§á§à§Ý§ß§ñ§ä§î §Þ§Ñ§ã§ã§à§Ó§í§Ö §Õ§Ö§Û§ã§ä§Ó§Ú§ñ §ã §ß§Ñ§Ò§à§â§à§Þ
  §Þ§à§Õ§Ö§Ý§Ö§Û

interface Geometria_Model_Collection_Interface
extends Iterator, Countable
{
  public function append(Geometria_Model $model);
  public function prepend(Geometria_Model $model);
  public function populate(array $data);
  public function clear();
  public function toArray();
}
§¯§å§Ø§Ö§ß Paginator?
class Geometria_Paginator_Adapter_Mapper
  implements Zend_Paginator_Adapter_Interface
{
  public function __construct(
    Geometria_Model_Mapper_Interface $mapper,
    array $cond = null,
    array $sort = null
  )
  {
    $this->_mapper = $mapper;
    $this->_cond   = $cond;
    $this->_sort   = $sort;
  }
}
§¯§å§Ø§Ö§ß Paginator?
class Geometria_Paginator_Adapter_Mapper
  ...
  public function getItems($offset, $limit)
  {
    return $this->_mapper->fetchAll(
       $this->_cond,
       $this->_sort,
       $limit,
       $offset
    );
  }

 public function count()
 {
   return $this->_mapper->getCount(
      $this->_cond,
      $this->_sort
   );
 }
§·§à§ä§Ú§Þ §Ü§Ö§ê§Ú§â§à§Ó§Ñ§ä§î, §Ý§à§Ô§Ú§â§à§Ó§Ñ§ä§î §Ú §ä§Õ.
? §ª§ã§á§à§Ý§î§Ù§å§Ö§Þ §Õ§Ö§Ü§à§â§Ñ§ä§à§â §Õ§Ý§ñ §Þ§Ñ§á§á§Ö§â§Ñ
? §¥§Ö§Ü§à§â§ä§Ñ§ä§à§â - §ï§ä§à §Þ§Ñ§ä§â§Ö§ê§Ü§Ñ: §Ó §Ü§à§ß§ã§ä§â§å§Ü§ä§à§â §á§Ö§â§Ó§à§Ô§à
  §Õ§Ö§Ü§à§â§Ñ§ä§à§â§Ñ §á§Ö§â§Ö§Õ§Ñ§Ö§Þ §Þ§Ñ§á§á§Ö§â, §Ó §Ü§à§ß§ã§ä§â§å§Ü§ä§à§â §Ó§ä§à§â§à§Ô§à
  §á§Ö§â§Ö§Õ§Ñ§Ö§Þ §á§Ö§â§Ó§í§Û §Õ§Ö§Ü§à§â§Ñ§ä§à§â §Ú §ä§Ñ§Ü §Õ§Ñ§Ý§Ö§Ö
? §¥§Ö§Ü§à§â§Ñ§ä§à§â §á§Ö§â§Ö§ç§Ó§Ñ§ä§í§Ó§Ñ§Ö§ä "§Ú§ß§ä§Ö§â§Ö§ã§å§ð§ë§Ú§Ö" §Ö§Ô§à §Þ§Ö§ä§à§Õ§í,
  §Ú §Ú§Ù§Þ§Ö§ß§ñ§Ö§ä §â§Ö§Ù§å§Ý§î§ä§Ñ§ä §ß§Ñ §Ö§Þ§å §å§Ô§à§Õ§ß§í§Û, §à§ã§ä§Ñ§Ý§î§ß§í§Ö
  §Þ§Ö§ä§à§Õ§í §á§â§à§ã§ä§à §á§â§à§á§å§ã§Ü§Ñ§Ö§ä §Õ§Ñ§Ý§î§ê§Ö.
? §±§â§Ú §Ú§ß§Ú§è§Ú§Ñ§Ý§Ú§Ù§Ñ§è§Ú§Ú §Þ§Ñ§á§á§Ö§â§Ñ §Þ§Ñ§á§á§Ö§â-§Þ§Ö§ß§Ö§Õ§Ø§Ö§â
  §ã§á§â§Ñ§ê§Ú§Ó§Ñ§Ö§ä §å §Þ§Ñ§á§á§Ö§â§Ñ, §ç§à§é§Ö§ä §Ý§Ú §à§ß
  §Ù§Ñ§Õ§Ö§Ü§à§â§Ú§â§à§Ó§Ñ§ä§î§ã§ñ §Ú §à§Ò§à§â§Ñ§é§Ú§Ó§Ñ§Ö§ä
  §Ó§à §Ó§ã§Ö §å§Ü§Ñ§Ù§Ñ§ß§ß§í§Ö §Õ§Ö§Ü§à§â§Ñ§ä§â§í
§±§â§Ú§Þ§Ö§â§í §Õ§Ö§Ü§à§â§Ñ§ä§à§â§à§Ó
Cache
? fetchOne(), fetchAll() - §ß§Ñ §à§ã§ß§à§Ó§Ñ§ß§Ú§Ú §á§Ö§â§Ö§Õ§Ñ§ß§ß§à§Ô§à §å§ã§Ý§à§Ó§Ú§ñ
  §Ò§Ö§â§Ö§ä §Õ§Ñ§ß§ß§í§Ö §Ú§Ù §Ü§Ö§ê§Ñ, §Ú§Ý§Ú §Ø§Ö §á§â§à§ã§Ú§ä §Þ§Ñ§á§á§Ö§â §Ó§í§á§à§Ý§ß§Ú§ä§î
  §Ù§Ñ§á§â§à§ã §Ú §Ü§Ö§ê§Ú§â§å§Ö§ä §Ö§Ô§à §â§Ö§Ù§å§Ý§î§ä§Ñ§ä.
? create(), update(), delete() - §ã§Ò§â§Ñ§ã§í§Ó§Ñ§Ö§ä §ã§à§à§ä§Ó§Ö§ä§ã§Ó§å§ð§ë§Ú§Û
  §Ü§Ö§ê.

Profiler
? §¥§Ö§Ü§à§â§Ñ§ä§à§â §á§â§à§á§å§ã§Ü§Ñ§Ö§ä §Ó§ã§Ö §Ù§Ñ§á§â§à§ã§í §é§Ö§â§Ö§Ù §ã§Ö§Ò§ñ,
   §Ù§Ñ§á§Ú§ã§í§Ó§Ñ§ñ §Ó §Ý§à§Ô §Ó§â§Ö§Þ§ñ §Ó§í§á§à§Ý§ß§Ö§ß§Ú§ñ §Ù§Ñ§á§â§à§ã§Ñ.

Identity Map
 ? §¬§Ö§ê§Ú§â§å§Ö§ä §â§Ö§Ù§å§Ý§î§ä§Ñ§ä§í §Ó §á§Ñ§Þ§ñ§ä§Ú, §é§ä§à§Ò§í §Þ§Ñ§á§á§Ö§â §ß§Ö
   §Ó§í§á§à§Ý§ß§ñ§Ý §à§Õ§Ú§ß§Ñ§Ü§à§Ó§í§Ö §Ù§Ñ§á§â§à§ã§í §Õ§Ó§Ñ§Ø§Õ§í
§°§ä§ß§à§ê§Ö§ß§Ú§ñ

§²§Ñ§Ù §å§Ø §ã§ä§â§à§Ú§Þ ORM, §ä§à §Õ§à§Ý§Ø§ß§í §Ò§í§ä§î §à§ä§ß§à§ê§Ö§ß§Ú§ñ §Þ§Ö§Ø§Õ§å
§ã§å§ë§ß§à§ã§ä§ñ§Þ§Ú.

? §°§ä§ß§à§ê§Ö§ß§Ú§ñ §ä§Ñ§Ü §Ø§Ö, §Ü§Ñ§Ü §Ú §á§à§Ý§ñ, §Ù§Ñ§Õ§Ñ§ð§ä§ã§ñ §Ó DocBlock
? §±§Ñ§â§Ñ§Þ§Ö§ä§â§í §à§á§Ú§ã§í§Ó§Ñ§ð§ä§ã§ñ §Ó §ã§á§Ö§è §æ§à§â§Þ§Ñ§ä§Ö
? §±§â§Ú §ã§à§Ù§Õ§Ñ§ß§Ú§Ú §Þ§à§Õ§Ö§Ý§Ú, §ã§à§Ù§Õ§Ñ§ð§ä§ã§ñ §à§Ò§ì§Ö§Ü§ä§í-§Þ§Ö§ß§Ö§Õ§Ø§Ö§â§í
  §à§ä§ß§à§ê§Ö§ß§Ú§Û
? §±§â§Ú §à§Ò§â§Ñ§ë§Ö§ß§Ú§Ú §Ü §á§à§Ý§ð, §ã§ã§í§Ý§Ñ§ð§ë§Ö§Þ§å§ã§ñ §ß§Ñ §Ó§ß§Ö§ê§ß§ð§ð
  §ã§å§ë§ß§à§ã§ä§î, §à§Ò§ì§Ö§Ü§ä-§Þ§Ö§ß§Ö§Õ§Ø§Ö§â §à§ä§ß§à§ê§Ö§ß§Ú§ñ §Õ§Ö§Ý§Ñ§Ö§ä §Ù§Ñ§á§â§à§ã §Ü
  §Ó§ß§Ö§ê§ß§Ö§Þ§å §Þ§Ñ§á§á§Ö§â§å §Ú §Ó§à§Ù§Ó§â§Ñ§ë§Ñ§Ö§ä §á§à§Ý§å§é§Ö§ß§í§Û §à§Ò§ì§Ö§Ü§ä.
§±§â§Ú§Þ§Ö§â §â§Ñ§Ò§à§ä§í §ã §à§ä§ß§à§ê§Ö§ß§Ú§ñ§Þ§Ú
/**
  * ...
  * @property integer $authorId
  * @property Model_Author $author
[relation=belongsTo;localKey=authorId]
  */
class Model_Post extends Geometria_Model
{...}

$post = Model_Post::getMapper()->fetchOne(array('authorId'
=> 5));
$author = $post->author; // Model_Author

§®§Ö§ß§Ö§Õ§Ø§Ö§â §à§ä§ß§à§ê§Ö§ß§Ú§ñ §Ó §Õ§Ñ§ß§ß§à§Þ §ã§Ý§å§é§Ñ§Ö §Ó§í§á§à§Ý§ß§Ú§ä §Ù§Ñ§á§â§à§ã

Model_Author::getMapper()->fetchOne(array('id' => 5));
§£§Ú§Õ§í §à§ä§ß§à§ê§Ö§ß§Ú§Û

? hasOne - one-to-one §à§ä§ß§à§ê§Ö§ß§Ú§Ö
? belongsTo - §ä§à§Ø§Ö §é§ä§à §Ú hasOne, §ß§à §ä§â§Ö§Ò§å§Ö§ä
  §à§Ò§ñ§Ù§Ñ§ä§Ö§Ý§î§ß§à§Ô§à §ß§Ñ§Ý§Ú§é§Ú§ñ §à§Ò§ì§Ö§Ü§ä§Ñ
? hasMany - one-to-many §à§ä§ß§à§ê§Ö§ß§Ú§Ö
§±§à§Ý§Ú§Þ§à§â§æ§Ú§é§Ö§ã§Ü§Ú§Ö §ã§Ó§ñ§Ù§Ú

§°§Ò§Ö§ã§á§Ö§é§Ú§Ó§Ñ§ð§ä §ã§Ó§ñ§Ù§î §ã §ß§Ö§ã§Ü§à§Ý§î§Ü§Ú§Þ§Ú §Ó§Ú§Õ§Ñ§Þ§Ú §ã§å§ë§ß§à§ã§ä§Ö§Û, §ä§à
§ß§Ñ §Ü§Ñ§Ü§à§Û §ä§Ú§á §ã§å§ë§ß§à§ã§ä§Ú §ã§ä§à§Ú§ä §ã§ã§í§Ý§Ü§Ñ §à§á§â§Ö§Õ§Ö§Ý§ñ§Ö§ä §á§Ñ§â§Ñ§Þ§Ö§ä§â
ownerType, §Ó §ä§à §Ó§â§Ö§Þ§ñ §Ü§Ñ§Ü §á§Ñ§â§Ñ§Þ§Ö§ä§â ownerTypeId
§à§á§â§Ö§Õ§Ö§Ý§ñ§Ö§ä id §ã§å§ë§ß§à§ã§ä§Ú.

/**
  * @property string $ownerType
  * @property integer $ownerId
  * @property Model_User|Model_Post $owner
[relation=polymorhic; localKey=ownerId;
localTypeKey=ownerType]
  */
class Model_Comment extends Geometria_Model
{..}
§´§à§ß§Ü§à§ã§ä§Ú §à§ä§ß§à§ê§Ö§ß§Ú§Û

$posts = Model_Post::getMapper()->fetchAll();

foreach ($posts as $post) {
    echo $post->title . ' by ' . $post->author;
}

§¡§Ó§ä§à§â §Ù§Ñ§á§â§Ñ§ê§Ú§Ó§Ñ§Ö§ä§ã§ñ §á§â§Ú §Ü§Ñ§Ø§Õ§à§Û §Ú§ä§Ö§â§Ñ§è§Ú§Ú.

§¦§ã§Ý§Ú §å §ß§Ñ§ã 10 §á§à§ã§ä§à§Ó, §Ù§ß§Ñ§é§Ú§ä §Þ§í §ã§Õ§Ö§Ý§Ñ§Ö§Þ 1 §Ù§Ñ§á§â§à§ã §ß§Ñ
§á§à§Ý§å§é§Ö§ß§Ú§Ö §á§à§ã§ä§à§Ó §Ú 10 §Ù§Ñ§á§â§à§ã§à§Ó §ß§Ñ §á§à§Ý§å§é§Ö§ß§Ú§Ö §Ñ§Ó§ä§à§â§à§Ó.
§ª§ä§à§Ô§à 11 §Ù§Ñ§á§â§à§ã§à§Ó - §á§Ý§à§ç§à!
§´§à§ß§Ü§à§ã§ä§Ú §à§ä§ß§à§ê§Ö§ß§Ú§Û

§²§Ö§ê§Ö§ß§Ú§Ö:

$posts->fetchRelations('author');

§±§â§à§ã§Ú§Þ relation-manager §á§à§Ý§å§é§Ú§ä§î §Ó§ã§Ö§ç §Ñ§Ó§ä§à§â§à§Ó §à§Õ§ß§Ú§Þ
§Ù§Ñ§á§â§à§ã§à§Þ §Ú §á§â§à§ã§ä§Ñ§Ó§Ú§ä§î §Ó§à §Ó§ã§Ö§ç §á§à§ã§ä§Ñ§ç §Ü§à§Ý§Ý§Ö§Ü§è§Ú§Ú.

§ª§ä§à§Ô§à: 2 §Ù§Ñ§á§â§à§ã§Ñ, §ß§Ö§Ù§Ñ§Ó§Ú§ã§Ú§Þ§à §à§ä §Ü§à§Ý§Ú§é§Ö§ã§ä§Ó§Ñ §á§à§ã§ä§à§Ó.
§´§à§ß§Ü§à§ã§ä§Ú §à§ä§ß§à§ê§Ö§ß§Ú§Û

§¡ §Ö§ã§Ý§Ú §å §Ñ§Ó§ä§à§â§Ñ §Ö§ã§ä§î §ã§Ó§ñ§Ù§î §ã §Ü§Ñ§â§ä§Ú§ß§Ü§à§Û-§Ñ§Ó§Ñ§ä§Ñ§â§Ü§à§Û?

$posts->fetchRelations('author', 'picture');

§¹§ä§à §à§Ù§ß§Ñ§é§Ñ§Ö§ä, §é§ä§à §á§Ö§â§Ö§Õ §ä§Ö§Þ, §Ü§Ñ§Ü "§â§Ñ§ã§á§Ú§ç§Ñ§ä§î" §Ó§ã§Ö§ç §Ñ§Ó§ä§à§â§à§Ó
§á§à §á§à§ã§ä§Ñ§Þ, §å §á§à§Ý§å§é§Ö§ß§ß§à§Û §Ü§à§Ý§Ý§Ö§Ü§è§Ú§Ú §Ñ§Ó§ä§à§â§à§Ó §Ò§å§Õ§Ö§ä
§Ó§í§Ù§Ó§Ñ§ß §Þ§Ö§ä§à§Õ:

$authors->fetchRelations('picture');
§¬§Ñ§ã§Ü§Ñ§Õ§ß§í§Ö §à§á§Ö§â§Ñ§è§Ú§Ú

§µ §à§ä§ß§à§ê§Ö§ß§Ú§Û §Þ§à§Ø§ß§à §á§â§à§á§Ú§ã§Ñ§ä§î §Õ§Ö§Û§ã§ä§Ó§Ú§Ö, §Ü§à§ä§à§â§à§Ö §Ò§å§Õ§Ö§ä
§Ó§í§á§à§Ý§ß§ñ§ä§î§ã§ñ §á§â§Ú §å§Õ§Ñ§Ý§Ö§ß§Ú§Ú §Þ§à§Õ§Ö§Ý§Ú onDelete:
 ? CASCADE - §å§Õ§Ñ§Ý§Ú§ä§î §Ó§ã§Ö §ã§Ó§ñ§Ù§Ñ§ß§ß§í§Ö §Ù§Ñ§Ó§Ú§ã§Ú§Þ§í§Ö §Þ§à§Õ§Ö§Ý§Ú
 ? SET NULL - §à§é§Ú§ã§ä§Ú§ä§î §Ù§ß§Ñ§é§Ö§ß§Ú§ñ §Ó§ß§Ö§ê§ß§Ú§ç §Ü§Ý§ð§é§Ö§Û

§¿§ä§à §á§à§Ù§Ó§à§Ý§ñ§Ö§ä §ã§à§ç§â§Ñ§ß§ñ§ä§î §è§Ö§Ý§à§ã§ä§ß§à§ã§ä§î §ã§Ó§ñ§Ù§Ö§Û §Ó§ß§å§ä§â§Ú
§ß§Ñ§ê§Ö§Û §ã§Ú§ã§ä§Ö§Þ§í.
§¨§Ú§Ù§ß§î §Ò§Ö§Ù Join'§à§Ó

§¬§Ñ§Ü §ã§Õ§Ö§Ý§Ñ§ä§î §Ó§í§Ò§à§â§Ü§å §á§à§ã§ä§à§Ó, §ß§Ñ§á§Ú§ã§Ñ§ß§ß§í§ç §Ø§Ö§ß§ë§Ú§ß§Ñ§Þ§Ú, §Ö§ã§Ý§Ú
§á§à§ã§ä§í §Ú§ã§á§à§Ý§î§Ù§å§ð§ä §à§Õ§ß§à §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö, §Ñ §Ñ§Ó§ä§à§â§í §Õ§â§å§Ô§à§Ö, §Ú §ß§Ö§ä
§Ó§à§Ù§Þ§à§Ø§ß§à§ã§ä§Ú §ã§Õ§Ö§Ý§Ñ§ä§î join?

§ª§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î sphinx.

?   §³§à§Ù§Õ§Ñ§Ö§Þ §Ú§ß§Õ§Ö§Ü§ã §Ó §ã§æ§Ú§ß§Ü§ã§Ö §Õ§Ý§ñ §ä§Ñ§Ü§à§Ô§à §â§à§Õ§Ñ §Ó§í§Ò§à§â§Ü§Ú.
?   §ª§ß§Õ§Ö§Ü§ã§Ú§â§å§Ö§Þ §Õ§Ñ§ß§ß§í§Ö.
?   §³§à§Ù§Õ§Ñ§Ö§Þ sphinx §Õ§Ö§Ü§à§â§Ñ§ä§à§â
?   §¥§Ö§Ü§à§â§Ñ§ä§à§â §Ú§ë§Ö§ä id §Õ§à§Ü§å§Þ§Ö§ß§ä§à§Ó, §å§Õ§à§Ó§Ý§Ö§ä§Ó§à§â§ñ§ð§ë§Ú§ç
    §á§à§Ú§ã§Ü§à§Ó§à§Þ§å §Ù§Ñ§á§â§à§ã§å. §ª §á§à §ï§ä§à§Þ §ã§á§Ú§ã§Ü§å id §Þ§Ñ§á§á§Ö§â
    §Ó§à§Ù§Ó§â§Ñ§ë§Ñ§Ö§ä §Ü§à§Ý§Ý§Ö§Ü§è§Ú§ð §ã §â§Ö§Ù§å§Ý§î§ä§Ñ§ä§à§Þ.
§¹§ä§à §Õ§Ñ§Ý§à §Ó§ß§Ö§Õ§â§Ö§ß§Ú§Ö ORM

? §³§å§ë§Ö§ã§ä§Ó§Ö§ß§ß§à§Ö §å§ã§Ü§à§â§Ö§ß§Ú§Ö §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú
? §£§â§Ö§Þ§ñ §Ó§ç§à§Ø§Õ§Ö§ß§Ú§ñ §Ó §é§å§Ø§à§Û §Ü§à§Õ §Ù§ß§Ñ§é§Ú§ä§Ö§Ý§î§ß§à
  §å§Þ§Ö§ß§î§ê§Ú§Ý§à§ã§î
? §ª§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ß§Ú§Ö Domain Driven Design §á§à§Ù§Ó§à§Ý§ñ§Ö§ä
  §Ô§à§Ó§à§â§Ú§ä§î §ß§Ñ §ñ§Ù§í§Ü§Ö §á§â§Ö§Õ§Þ§Ö§ä§ß§à§Û §à§Ò§Ý§Ñ§ã§ä§Ú, §é§ä§à §á§à§Ó§í§ê§Ñ§Ö§ä
  §é§Ú§ä§Ñ§Ö§Þ§à§ã§ä§î §Ü§à§Õ§Ñ
? §­§à§Ô§Ú§Ü§Ñ §á§â§Ú§Ý§à§Ø§Ö§ß§Ú§ñ §Ó§í§ß§Ö§ã§Ö§ß§Ñ §Ó §à§ä§Õ§Ö§Ý§î§ß§í§Û §ã§Ý§à§Û
  §ã§Ö§â§Ó§Ú§ã§à§Ó. §¹§ä§à §á§à§Ù§Ó§à§Ý§ñ§Ö§ä §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î §Ö§Ö §ß§Ö §ä§à§Ý§î§Ü§à §Ó
  MVC, §ß§à §Ú §Ó CLI, §ß§Ñ§á§â§Ú§Þ§Ö§â.
? §²§Ñ§Ù§Þ§Ö§â §ï§Ü§ê§Ö§ß§à§Ó §Ó §Ü§à§ß§ä§â§à§Ý§Ý§Ö§â§Ñ§ç §ã§à§Ü§â§Ñ§ä§Ú§Ý§ã§ñ §Õ§à 10 §ã§ä§â§à§Ü.
§¢§å§Õ§Ö§ä §Ý§Ú open source?

§¢§å§Õ§Ö§ä, §ß§à §á§à§Ù§Ø§Ö )
§³§á§Ñ§ã§Ú§Ò§à

Twitter: @munk13

§®§à§Û§¬§â§å§Ô: http://munkie.moikrug.ru

More Related Content

§´§à§Ý§ã§ä§Ñ§ñ §Þ§à§Õ§Ö§Ý§î. §ª§ã§ä§à§â§Ú§ñ §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ORM

  • 1. §´§à§Ý§ã§ä§Ñ§ñ §Þ§à§Õ§Ö§Ý§î §ª§ã§ä§à§â§Ú§ñ §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ORM §º§Ñ§Þ§Ú§ß §®§Ú§ç§Ñ§Ú§Ý Geometria.ru §£§Ö§Õ§å§ë§Ú§Û §â§Ñ§Ù§â§Ñ§Ò§à§ä§é§Ú§Ü
  • 3. Geometria.ru ? §¤§Ý§Ñ§Ó§ß§í§Û §æ§à§ä§à§ç§â§à§ß§Ú§Ü§Ö§â §ã§ä§â§Ñ§ß§í ? 8 §Ý§Ö§ä §ß§Ñ §â§í§ß§Ü§Ö ? §±§â§Ö§Õ§ã§ä§Ñ§Ó§Ú§ä§Ö§Ý§î§ã§ä§Ó§à §Ó 150 §Ô§à§â§à§Õ§Ñ§ç §²§à§ã§ã§Ú§Ú, §³§¯§¤ §Ú §±§â§Ú§Ò§Ñ§Ý§ä§Ú§Ü§Ú ? §¦§Ø§Ö§Õ§ß§Ö§Ó§ß§à 80 000 §á§à§Ý§î§Ù§à§Ó§Ñ§ä§Ö§Ý§Ö§Û / 600 000 §á§â§à§ã§Þ§à§ä§â§à§Ó ? §£ §á§à§ß§Ö§Õ§Ö§Ý§î§ß§Ú§Ü 110 000 / 1 000 000 ? §¢§à§Ý§Ö§Ö 500 000 §â§Ö§á§à§â§ä§Ñ§Ø§Ö§Û ? 15 000 000 §æ§à§ä§à§Ô§â§Ñ§æ§Ú§Û ? 800 000 §Ù§Ñ§â§Ö§Ô§Ú§ã§ä§â§Ú§â§à§Ó§Ñ§ß§ß§í§ç §á§à§Ý§î§Ù§à§Ó§Ñ§ä§Ö§Ý§Ö§Û
  • 5. §±§à§é§Ö§Þ§å §á§à§ß§Ñ§Õ§à§Ò§Ú§Ý§ã§ñ §ã§Ó§à§Û ORM §¢§í§Ý§à ? §¯§Ñ§ã§Ý§Ö§Õ§ã§ä§Ó§à §Ó §Ó§Ú§Õ§Ö §Ù§Ñ§Ý§Ö§Ø§Ö§Û §Ü§à§Õ§Ñ-§Ý§Ñ§á§ê§Ú ? §±§â§Ñ§Ü§ä§Ú§é§Ö§ã§Ü§Ú §Ó§ã§ñ §Ò§Ú§Ù§ß§Ö§ã-§Ý§à§Ô§Ú§Ü§Ñ §Ó §Ü§à§ß§ä§â§à§Ý§Ý§Ö§â§Ñ§ç ? §£§á§Ý§à§ä§î §Õ§à §æ§à§â§Þ§Ú§â§à§Ó§Ñ§ß§Ú§ñ select §à§Ó! ? §¯§Ö§Ü§à§ä§à§â§í§Ö §ï§Ü§ê§Ö§ß§í §â§Ñ§Ù§Þ§Ö§â§à§Þ §Ó 200 §ã§ä§â§à§Ü! ? §£ §â§à§Ý§Ú §Þ§à§Õ§Ö§Ý§Ú - Zend_Db_Table
  • 6. §±§à§é§Ö§Þ§å §á§à§ß§Ñ§Õ§à§Ò§Ú§Ý§ã§ñ §ã§Ó§à§Û ORM §³§ä§Ñ§Ý§à ? §³§ä§Ñ§Ý§Ú §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î NoSQL §â§Ö§ê§Ö§ß§Ú§ñ, §ä§Ñ§Ü§Ú§Ö §Ü§Ñ§Ü Redis §Ú Mongo ? §±§à§ß§Ñ§Õ§à§Ò§Ú§Ý§à§ã§î §â§Ö§ê§Ö§ß§Ú§Ö, §Ô§à§ä§à§Ó§à§Ö §â§Ñ§Ò§à§ä§Ñ§ä§î §ã §Ý§ð§Ò§í§Þ §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö§Þ, §Ñ §ß§Ö §ä§à§Ý§î§Ü§à SQL ? §¦§ã§ä§î §Ý§Ú §é§ä§à-§ä§à §ß§Ñ §â§í§ß§Ü§Ö? ? Doctrine2 §Ó alph§Ñ, §Ö§ë§Ö §ã§í§â§Ñ§ñ - §ã§ä§â§Ñ§ê§ß§à. ? §¹§ä§à §Õ§Ö§Ý§Ñ§ä§î? ? §±§Ú§ê§Ö§Þ §ã§Ó§à§Û §Ó§Ö§Ý§à§ã§Ú§á§Ö§Õ!
  • 7. §£§í§Ò§à§â §Õ§Ú§Ù§Ñ§Û§ß§Ñ §°§ä§Ü§â§í§Ó§Ñ§Ö§Þ §Ü§ß§Ú§Ô§å §®§Ñ§â§ä§Ú§ß§Ñ §¶§Ñ§å§Ý§Ö§â§Ñ (Martin Fowler) "§º§Ñ§Ò§Ý§à§ß§í §Ü§à§â§á§à§â§Ñ§ä§Ú§Ó§ß§í§ç §á§â§Ú§Ý§à§Ø§Ö§ß§Ú§Û" ("Patterns of Enterprise Application Architecture")
  • 9. §£§í§Ò§à§â §Õ§Ú§Ù§Ñ§Û§ß§Ñ §ª §ß§Ñ§ç§à§Õ§Ú§Þ §ä§à §é§ä§à §ß§å§Ø§ß§à. Domain Model §Ú§Ý§Ú §®§à§Õ§Ö§Ý§î §á§â§Ö§Õ§Þ§Ö§ä§ß§à§Û §à§Ò§Ý§Ñ§ã§ä§Ú
  • 10. §±§à§Ý§ñ §Þ§à§Õ§Ö§Ý§Ú. §¬§Ñ§Ü §Ù§Ñ§Õ§Ñ§Ó§Ñ§ä§î ? ? §£ Zend_Db_Table_Row §á§à§Ý§ñ §ß§Ö §á§â§à§á§Ú§ã§Ñ§ß§í §ñ§Ó§ß§à, §Ñ §Ò§Ö§â§å§ä§ã§ñ §Ú§Ù §ã§ç§Ö§Þ§í §ä§Ñ§Ò§Ý§Ú§è§í §¢§¥ ? §£ Doctrine2 §é§Ö§â§Ö§Ù §Ù§Ñ§Õ§Ñ§ß§Ú§Ö private/protected §ã§Ó§à§Û§ã§ä§Ó §Ú §Ô§Ö§ß§Ö§â§Ñ§è§Ú§ð getter/setter §Þ§Ö§ä§à§Õ§à§Ó.
  • 11. §±§à§Ý§ñ §Þ§à§Õ§Ö§Ý§Ú. §²§Ö§ê§Ö§ß§Ú§Ö: §ª§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î DocBlock §±§â§à§æ§Ú§ä§í: ? §¤§à§ä§à§Ó§í§Û §ê§Ñ§Ò§Ý§à§ß §Õ§Ý§ñ §ä§Ú§á§à§Ó §Õ§Ñ§ß§ß§í§ç ? §³§â§Ñ§Ù§å §Ó §Ñ§ß§ß§à§ä§Ñ§è§Ú§Ú §Ü§Ý§Ñ§ã§ã§Ñ §Ó§Ú§Õ§ß§í §Ó§ã§Ö §á§à§Ý§ñ §Þ§à§Õ§Ö§Ý§Ú ? §¡§Ó§ä§à§Ü§à§Þ§á§Ý§Ú§ä §Ó IDE (Zend Studio, PhpStorm, NetBeans) ? §¢§í§ã§ä§â§à§Ö §ã§à§Ù§Õ§Ñ§ß§Ú§Ö §Ü§Ý§Ñ§ã§ã§à§Ó
  • 12. Zend_Reflection §Õ§Ý§ñ §Ô§Ö§ß§Ö§â§Ñ§è§Ú§Ú §á§à§Ý§Ö§Û /** * @property integer $id * @property string $title * @property string $body * @property boolean $hidden * @property integer $date **/ class Model_Post extends Geometria_Model { }
  • 13. Zend_Reflection §Õ§Ý§ñ §Ô§Ö§ß§Ö§â§Ñ§è§Ú§Ú §á§à§Ý§Ö§Û §±§à§ã§Ý§Ö $post = new Model_Post(); §ã§Ó§à§Û§ã§ä§Ó§à $_data §Ò§å§Õ§Ö§ä §Ó§í§Ô§Ý§ñ§Õ§Ö§ä§î §ã§Ý§Ö§Õ§å§ð§ë§Ú§Þ §à§Ò§â§Ñ§Ù§à§Þ: class Model_Post extends Geometria_Model { protected $_data = array( 'id' => null, 'title' => null, 'body' => null, 'hidden' => null, 'date' => null, ); }
  • 14. §¥§à§ã§ä§å§á §Ü §á§à§Ý§ñ§Þ ? §£§ß§Ö§ê§ß§Ú§Û §Õ§à§ã§ä§å§á §Ü §á§à§Ý§ñ§Þ §à§Ò§Ö§ã§á§Ö§é§Ú§Ó§Ñ§Ö§ä§ã§ñ §é§Ö§â§Ö§Ù §Þ§Ñ§Ô§Ú§é§Ö§ã§Ü§Ú§Ö §Þ§Ö§ä§à§Õ§í __get() §Ú __set() ? §®§à§Ø§ß§à §â§Ö§Ñ§Ý§Ú§Ù§à§Ó§Ñ§ä§î §Þ§Ö§ä§à§Õ§í get<§á§à§Ý§Ö> §Ú set<§á§à§Ý§Ö>, §é§ä§à§Ò§í §Ú§Ù§Þ§Ö§ß§Ú§ä§î §Ý§à§Ô§Ú§Ü§å §å§ã§ä§Ñ§ß§à§Ó§Ü§Ú/§á§à§Ý§å§é§Ö§ß§Ú§ñ §Ù§ß§Ñ§é§Ö§ß§Ú§ñ §á§à§Ý§ñ.
  • 15. /** * ... * @property integer $date Unix timestamp */ class Model_Post extends Geometria_Model ... public function setDate($value) { if ($value instanceof Zend_Date) { $value = $value->getTimestamp(); } $this->_data['date'] = $value; }
  • 16. §µ§ã§ä§Ñ§ß§à§Ó§Ü§Ñ §Ù§ß§Ñ§é§Ö§ß§Ú§ñ §á§à §å§Þ§à§Ý§é§Ñ§ß§Ú§ð class Model_Post extends Geometria_Model ... public function getDate($value) { if (null === $this->_data['date']) { $this->_data['date'] = time(); } return $this->_data['date']; }
  • 17. §¬§Ñ§Ü §ç§â§Ñ§ß§Ú§ä§î §Þ§à§Õ§Ö§Ý§î? §ª§ã§á§à§Ý§î§Ù§å§Ö§Þ DataMapper ? §®§Ñ§á§á§Ö§â §Ù§ß§Ñ§Ö§ä §Ó§ã§Ö §à §Þ§à§Õ§Ö§Ý§Ú §Ú §à §ä§à§Þ, §Ü§Ñ§Ü §Ú §Ô§Õ§Ö §Ö? §ç§â§Ñ§ß§Ú§ä§î. ? §®§à§Õ§Ö§Ý§î §ß§Ú§é§Ö§Ô§à §ß§Ö §Ù§ß§Ñ§Ö§ä §à §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö. ? §­§à§Ô§Ú§Ü§Ñ §Õ§à§Þ§Ö§ß§Ñ §à§ä§Õ§Ö§Ý§Ö§ß§Ñ §à§ä persist §Ý§à§Ô§Ú§Ü§Ú ? §®§à§Ø§ß§à §Þ§Ö§ß§ñ§ä§î §ã§ä§â§å§Ü§ä§å§â§å §Ò§Õ §Ú§Ý§Ú §Õ§Ñ§Ø§Ö §ã§Þ§Ö§ß§Ú§ä§î §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö, §ß§Ö §Þ§Ö§ß§ñ§ñ §Ý§à§Ô§Ú§Ü§å §Þ§à§Õ§Ö§Ý§Ú, §Ó§ã§Ö§Ô§à §Ý§Ú§ê§î §Ú§Ù§Þ§Ö§ß§Ú§Ó §Þ§Ñ§á§á§Ö§â. ? §®§Ñ§á§á§Ö§â §Ó§í§á§à§Ý§ß§ñ§Ö§ä CRUD §à§á§Ö§â§Ñ§è§Ú§Ú ? §®§à§Ø§ß§à §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î §Ý§ð§Ò§à§Ö §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö: MySQL, Mongo, Redis, Config file, RESTApi §Ú §Õ§â.
  • 18. §ª§ß§ä§Ö§â§æ§Ö§Û§ã §Þ§Ñ§á§á§Ö§â§Ñ interface Geometria_Model_Mapper_Interface { public function create(Geometria_Model $model); public function update(Geometria_Model $model); public function delete(Geometria_Model $model); public function fetchOne($cond, $sort); public function fetchAll($cond, $sort, $limit, $skip); public function getCount($cond); }
  • 19. §²§Ñ§Ò§à§ä§Ñ §ã §Þ§à§Õ§Ö§Ý§î§ð $post = new Model_Post(); $post->title = 'hello world!'; $post->body = 'foo bar'; $postMapper = new Model_Post_Mapper(); $postMapper->create($post); echo $post->id; // 1 §Þ§Ñ§á§á§Ö§â §ã§Ñ§Þ §á§â§à§ã§ä§Ñ§Ó§Ú§Ý §Ó §Þ§à§Õ§Ö§Ý§Ú id
  • 20. §£§í§Ò§à§â§Ü§Ú ? §µ§ã§Ý§à§Ó§Ú§Ö $cond - §á§â§à§ã§ä§à§Û §Þ§Ñ§ã§ã§Ú§Ó §Ú§Þ§ñ §á§à§Ý§ñ => §Ù§ß§Ñ§é§Ö§ß§Ú§Ö ? §³§à§â§ä§Ú§â§à§Ó§Ü§Ñ $sort - §ä§à§Ø§Ö §á§â§à§ã§ä§à §Þ§Ñ§ã§ã§Ú§Ó §Ú§Þ§ñ §á§à§Ý§ñ => (bool) §ß§Ñ§á§â§Ñ§Ó§Ý§Ö§ß§Ú§Ö §ã§à§â§ä§Ú§â§à§Ó§Ü§Ú ? §¥§Ý§ñ §Ò§à§Ý§Ö§Ö §ã§Ý§à§Ø§ß§í§ç §Ó§í§Ò§à§â§à§Ü §á§Ú§ê§Ö§Þ §à§ä§Õ§Ö§Ý§î§ß§í§Û §Þ§Ö§ä§à§Õ §£§í§Ò§â§Ñ§ä§î 10 §ã§Ü§â§í§ä§í§ç §á§à§ã§ä§à§Ó, §ß§Ñ§é§Ú§ß§Ñ§ñ §ã §ã§Ñ§Þ§í§ç §ß§à§Ó§í§ç $mapper->fetchAll( array('hidden' => true), array('date' => false), 10 );
  • 21. §¥§Ö§Ý§Ñ§Ö§Þ ActiveRecord §²§Ñ§ã§ã§Ü§Ñ§Ù§í§Ó§Ñ§Ö§Þ §Þ§à§Õ§Ö§Ý§Ú, §é§ä§à §å §ß§Ö§Ö §Ö§ã§ä§î §Þ§Ñ§á§á§Ö§â. ? §¥§Ö§Ý§Ñ§Ö§Þ §ã§ä§Ñ§ä§Ú§é§Ö§ã§Ü§Ú§Û §Þ§Ö§ä§à§Õ getMapper() §Ü§à§ä§à§â§í§Û §Ú§Ù §ã§á§Ö§è§Ú§Ñ§Ý§î§ß§à§Ô§à §Ü§à§ß§ä§Ö§Û§ß§Ö§â§Ñ Geometria_Model_Mapper_Manager §Õ§à§ã§ä§Ñ§Ö§ä §ß§å§Ø§ß§í§Û §Ö§Û §Þ§Ñ§á§á§Ö§â ? §¥§Ö§Ý§Ñ§Ö§Þ §å §Þ§à§Õ§Ö§Ý§Ú §Þ§Ö§ä§à§Õ§í create(), update(), delete() public function create() { return self::getMapper()->create($this); }
  • 22. §´§Ö§á§Ö§â§î §ã§à§Ù§Õ§Ñ§ß§Ú§Ö §Þ§à§Õ§Ö§Ý§Ú §Ó§í§Ô§Ý§ñ§Õ§Ú§ä §ä§Ñ§Ü: $post = new Model_Post(); $post->title = 'hello world!'; $post->body = 'foo bar'; $post->create(); echo $post->id; // 1 §¡ §á§à§ã§ä §Þ§à§Ø§ß§à §á§à§Ý§å§é§Ú§ä§î §Ó §à§Õ§ß§å §ã§ä§â§à§é§Ü§å: $post = Model_Post::getMapper()->fetchOne( array('id' => 1) ); §Ú§Ý§Ú §ä§Ñ§Ü $post = Model_Post::getMapper()->fetch(1);
  • 23. §¹§ä§à §Ó§Ö§â§ß§Ö§ä fetchAll()? §¬§à§Ý§Ý§Ö§Ü§è§Ú§ð! ? §Ñ§ß§Ñ§Ý§à§Ô Zend_Db_Table_Rowset ? §±§Ñ§ä§ä§Ö§â§ß Record Set ? §±§à§Ù§Ó§à§Ý§ñ§Ö§ä §Ó§í§á§à§Ý§ß§ñ§ä§î §Þ§Ñ§ã§ã§à§Ó§í§Ö §Õ§Ö§Û§ã§ä§Ó§Ú§ñ §ã §ß§Ñ§Ò§à§â§à§Þ §Þ§à§Õ§Ö§Ý§Ö§Û interface Geometria_Model_Collection_Interface extends Iterator, Countable { public function append(Geometria_Model $model); public function prepend(Geometria_Model $model); public function populate(array $data); public function clear(); public function toArray(); }
  • 24. §¯§å§Ø§Ö§ß Paginator? class Geometria_Paginator_Adapter_Mapper implements Zend_Paginator_Adapter_Interface { public function __construct( Geometria_Model_Mapper_Interface $mapper, array $cond = null, array $sort = null ) { $this->_mapper = $mapper; $this->_cond = $cond; $this->_sort = $sort; } }
  • 25. §¯§å§Ø§Ö§ß Paginator? class Geometria_Paginator_Adapter_Mapper ... public function getItems($offset, $limit) { return $this->_mapper->fetchAll( $this->_cond, $this->_sort, $limit, $offset ); } public function count() { return $this->_mapper->getCount( $this->_cond, $this->_sort ); }
  • 26. §·§à§ä§Ú§Þ §Ü§Ö§ê§Ú§â§à§Ó§Ñ§ä§î, §Ý§à§Ô§Ú§â§à§Ó§Ñ§ä§î §Ú §ä§Õ. ? §ª§ã§á§à§Ý§î§Ù§å§Ö§Þ §Õ§Ö§Ü§à§â§Ñ§ä§à§â §Õ§Ý§ñ §Þ§Ñ§á§á§Ö§â§Ñ ? §¥§Ö§Ü§à§â§ä§Ñ§ä§à§â - §ï§ä§à §Þ§Ñ§ä§â§Ö§ê§Ü§Ñ: §Ó §Ü§à§ß§ã§ä§â§å§Ü§ä§à§â §á§Ö§â§Ó§à§Ô§à §Õ§Ö§Ü§à§â§Ñ§ä§à§â§Ñ §á§Ö§â§Ö§Õ§Ñ§Ö§Þ §Þ§Ñ§á§á§Ö§â, §Ó §Ü§à§ß§ã§ä§â§å§Ü§ä§à§â §Ó§ä§à§â§à§Ô§à §á§Ö§â§Ö§Õ§Ñ§Ö§Þ §á§Ö§â§Ó§í§Û §Õ§Ö§Ü§à§â§Ñ§ä§à§â §Ú §ä§Ñ§Ü §Õ§Ñ§Ý§Ö§Ö ? §¥§Ö§Ü§à§â§Ñ§ä§à§â §á§Ö§â§Ö§ç§Ó§Ñ§ä§í§Ó§Ñ§Ö§ä "§Ú§ß§ä§Ö§â§Ö§ã§å§ð§ë§Ú§Ö" §Ö§Ô§à §Þ§Ö§ä§à§Õ§í, §Ú §Ú§Ù§Þ§Ö§ß§ñ§Ö§ä §â§Ö§Ù§å§Ý§î§ä§Ñ§ä §ß§Ñ §Ö§Þ§å §å§Ô§à§Õ§ß§í§Û, §à§ã§ä§Ñ§Ý§î§ß§í§Ö §Þ§Ö§ä§à§Õ§í §á§â§à§ã§ä§à §á§â§à§á§å§ã§Ü§Ñ§Ö§ä §Õ§Ñ§Ý§î§ê§Ö. ? §±§â§Ú §Ú§ß§Ú§è§Ú§Ñ§Ý§Ú§Ù§Ñ§è§Ú§Ú §Þ§Ñ§á§á§Ö§â§Ñ §Þ§Ñ§á§á§Ö§â-§Þ§Ö§ß§Ö§Õ§Ø§Ö§â §ã§á§â§Ñ§ê§Ú§Ó§Ñ§Ö§ä §å §Þ§Ñ§á§á§Ö§â§Ñ, §ç§à§é§Ö§ä §Ý§Ú §à§ß §Ù§Ñ§Õ§Ö§Ü§à§â§Ú§â§à§Ó§Ñ§ä§î§ã§ñ §Ú §à§Ò§à§â§Ñ§é§Ú§Ó§Ñ§Ö§ä §Ó§à §Ó§ã§Ö §å§Ü§Ñ§Ù§Ñ§ß§ß§í§Ö §Õ§Ö§Ü§à§â§Ñ§ä§â§í
  • 27. §±§â§Ú§Þ§Ö§â§í §Õ§Ö§Ü§à§â§Ñ§ä§à§â§à§Ó Cache ? fetchOne(), fetchAll() - §ß§Ñ §à§ã§ß§à§Ó§Ñ§ß§Ú§Ú §á§Ö§â§Ö§Õ§Ñ§ß§ß§à§Ô§à §å§ã§Ý§à§Ó§Ú§ñ §Ò§Ö§â§Ö§ä §Õ§Ñ§ß§ß§í§Ö §Ú§Ù §Ü§Ö§ê§Ñ, §Ú§Ý§Ú §Ø§Ö §á§â§à§ã§Ú§ä §Þ§Ñ§á§á§Ö§â §Ó§í§á§à§Ý§ß§Ú§ä§î §Ù§Ñ§á§â§à§ã §Ú §Ü§Ö§ê§Ú§â§å§Ö§ä §Ö§Ô§à §â§Ö§Ù§å§Ý§î§ä§Ñ§ä. ? create(), update(), delete() - §ã§Ò§â§Ñ§ã§í§Ó§Ñ§Ö§ä §ã§à§à§ä§Ó§Ö§ä§ã§Ó§å§ð§ë§Ú§Û §Ü§Ö§ê. Profiler ? §¥§Ö§Ü§à§â§Ñ§ä§à§â §á§â§à§á§å§ã§Ü§Ñ§Ö§ä §Ó§ã§Ö §Ù§Ñ§á§â§à§ã§í §é§Ö§â§Ö§Ù §ã§Ö§Ò§ñ, §Ù§Ñ§á§Ú§ã§í§Ó§Ñ§ñ §Ó §Ý§à§Ô §Ó§â§Ö§Þ§ñ §Ó§í§á§à§Ý§ß§Ö§ß§Ú§ñ §Ù§Ñ§á§â§à§ã§Ñ. Identity Map ? §¬§Ö§ê§Ú§â§å§Ö§ä §â§Ö§Ù§å§Ý§î§ä§Ñ§ä§í §Ó §á§Ñ§Þ§ñ§ä§Ú, §é§ä§à§Ò§í §Þ§Ñ§á§á§Ö§â §ß§Ö §Ó§í§á§à§Ý§ß§ñ§Ý §à§Õ§Ú§ß§Ñ§Ü§à§Ó§í§Ö §Ù§Ñ§á§â§à§ã§í §Õ§Ó§Ñ§Ø§Õ§í
  • 28. §°§ä§ß§à§ê§Ö§ß§Ú§ñ §²§Ñ§Ù §å§Ø §ã§ä§â§à§Ú§Þ ORM, §ä§à §Õ§à§Ý§Ø§ß§í §Ò§í§ä§î §à§ä§ß§à§ê§Ö§ß§Ú§ñ §Þ§Ö§Ø§Õ§å §ã§å§ë§ß§à§ã§ä§ñ§Þ§Ú. ? §°§ä§ß§à§ê§Ö§ß§Ú§ñ §ä§Ñ§Ü §Ø§Ö, §Ü§Ñ§Ü §Ú §á§à§Ý§ñ, §Ù§Ñ§Õ§Ñ§ð§ä§ã§ñ §Ó DocBlock ? §±§Ñ§â§Ñ§Þ§Ö§ä§â§í §à§á§Ú§ã§í§Ó§Ñ§ð§ä§ã§ñ §Ó §ã§á§Ö§è §æ§à§â§Þ§Ñ§ä§Ö ? §±§â§Ú §ã§à§Ù§Õ§Ñ§ß§Ú§Ú §Þ§à§Õ§Ö§Ý§Ú, §ã§à§Ù§Õ§Ñ§ð§ä§ã§ñ §à§Ò§ì§Ö§Ü§ä§í-§Þ§Ö§ß§Ö§Õ§Ø§Ö§â§í §à§ä§ß§à§ê§Ö§ß§Ú§Û ? §±§â§Ú §à§Ò§â§Ñ§ë§Ö§ß§Ú§Ú §Ü §á§à§Ý§ð, §ã§ã§í§Ý§Ñ§ð§ë§Ö§Þ§å§ã§ñ §ß§Ñ §Ó§ß§Ö§ê§ß§ð§ð §ã§å§ë§ß§à§ã§ä§î, §à§Ò§ì§Ö§Ü§ä-§Þ§Ö§ß§Ö§Õ§Ø§Ö§â §à§ä§ß§à§ê§Ö§ß§Ú§ñ §Õ§Ö§Ý§Ñ§Ö§ä §Ù§Ñ§á§â§à§ã §Ü §Ó§ß§Ö§ê§ß§Ö§Þ§å §Þ§Ñ§á§á§Ö§â§å §Ú §Ó§à§Ù§Ó§â§Ñ§ë§Ñ§Ö§ä §á§à§Ý§å§é§Ö§ß§í§Û §à§Ò§ì§Ö§Ü§ä.
  • 29. §±§â§Ú§Þ§Ö§â §â§Ñ§Ò§à§ä§í §ã §à§ä§ß§à§ê§Ö§ß§Ú§ñ§Þ§Ú /** * ... * @property integer $authorId * @property Model_Author $author [relation=belongsTo;localKey=authorId] */ class Model_Post extends Geometria_Model {...} $post = Model_Post::getMapper()->fetchOne(array('authorId' => 5)); $author = $post->author; // Model_Author §®§Ö§ß§Ö§Õ§Ø§Ö§â §à§ä§ß§à§ê§Ö§ß§Ú§ñ §Ó §Õ§Ñ§ß§ß§à§Þ §ã§Ý§å§é§Ñ§Ö §Ó§í§á§à§Ý§ß§Ú§ä §Ù§Ñ§á§â§à§ã Model_Author::getMapper()->fetchOne(array('id' => 5));
  • 30. §£§Ú§Õ§í §à§ä§ß§à§ê§Ö§ß§Ú§Û ? hasOne - one-to-one §à§ä§ß§à§ê§Ö§ß§Ú§Ö ? belongsTo - §ä§à§Ø§Ö §é§ä§à §Ú hasOne, §ß§à §ä§â§Ö§Ò§å§Ö§ä §à§Ò§ñ§Ù§Ñ§ä§Ö§Ý§î§ß§à§Ô§à §ß§Ñ§Ý§Ú§é§Ú§ñ §à§Ò§ì§Ö§Ü§ä§Ñ ? hasMany - one-to-many §à§ä§ß§à§ê§Ö§ß§Ú§Ö
  • 31. §±§à§Ý§Ú§Þ§à§â§æ§Ú§é§Ö§ã§Ü§Ú§Ö §ã§Ó§ñ§Ù§Ú §°§Ò§Ö§ã§á§Ö§é§Ú§Ó§Ñ§ð§ä §ã§Ó§ñ§Ù§î §ã §ß§Ö§ã§Ü§à§Ý§î§Ü§Ú§Þ§Ú §Ó§Ú§Õ§Ñ§Þ§Ú §ã§å§ë§ß§à§ã§ä§Ö§Û, §ä§à §ß§Ñ §Ü§Ñ§Ü§à§Û §ä§Ú§á §ã§å§ë§ß§à§ã§ä§Ú §ã§ä§à§Ú§ä §ã§ã§í§Ý§Ü§Ñ §à§á§â§Ö§Õ§Ö§Ý§ñ§Ö§ä §á§Ñ§â§Ñ§Þ§Ö§ä§â ownerType, §Ó §ä§à §Ó§â§Ö§Þ§ñ §Ü§Ñ§Ü §á§Ñ§â§Ñ§Þ§Ö§ä§â ownerTypeId §à§á§â§Ö§Õ§Ö§Ý§ñ§Ö§ä id §ã§å§ë§ß§à§ã§ä§Ú. /** * @property string $ownerType * @property integer $ownerId * @property Model_User|Model_Post $owner [relation=polymorhic; localKey=ownerId; localTypeKey=ownerType] */ class Model_Comment extends Geometria_Model {..}
  • 32. §´§à§ß§Ü§à§ã§ä§Ú §à§ä§ß§à§ê§Ö§ß§Ú§Û $posts = Model_Post::getMapper()->fetchAll(); foreach ($posts as $post) { echo $post->title . ' by ' . $post->author; } §¡§Ó§ä§à§â §Ù§Ñ§á§â§Ñ§ê§Ú§Ó§Ñ§Ö§ä§ã§ñ §á§â§Ú §Ü§Ñ§Ø§Õ§à§Û §Ú§ä§Ö§â§Ñ§è§Ú§Ú. §¦§ã§Ý§Ú §å §ß§Ñ§ã 10 §á§à§ã§ä§à§Ó, §Ù§ß§Ñ§é§Ú§ä §Þ§í §ã§Õ§Ö§Ý§Ñ§Ö§Þ 1 §Ù§Ñ§á§â§à§ã §ß§Ñ §á§à§Ý§å§é§Ö§ß§Ú§Ö §á§à§ã§ä§à§Ó §Ú 10 §Ù§Ñ§á§â§à§ã§à§Ó §ß§Ñ §á§à§Ý§å§é§Ö§ß§Ú§Ö §Ñ§Ó§ä§à§â§à§Ó. §ª§ä§à§Ô§à 11 §Ù§Ñ§á§â§à§ã§à§Ó - §á§Ý§à§ç§à!
  • 33. §´§à§ß§Ü§à§ã§ä§Ú §à§ä§ß§à§ê§Ö§ß§Ú§Û §²§Ö§ê§Ö§ß§Ú§Ö: $posts->fetchRelations('author'); §±§â§à§ã§Ú§Þ relation-manager §á§à§Ý§å§é§Ú§ä§î §Ó§ã§Ö§ç §Ñ§Ó§ä§à§â§à§Ó §à§Õ§ß§Ú§Þ §Ù§Ñ§á§â§à§ã§à§Þ §Ú §á§â§à§ã§ä§Ñ§Ó§Ú§ä§î §Ó§à §Ó§ã§Ö§ç §á§à§ã§ä§Ñ§ç §Ü§à§Ý§Ý§Ö§Ü§è§Ú§Ú. §ª§ä§à§Ô§à: 2 §Ù§Ñ§á§â§à§ã§Ñ, §ß§Ö§Ù§Ñ§Ó§Ú§ã§Ú§Þ§à §à§ä §Ü§à§Ý§Ú§é§Ö§ã§ä§Ó§Ñ §á§à§ã§ä§à§Ó.
  • 34. §´§à§ß§Ü§à§ã§ä§Ú §à§ä§ß§à§ê§Ö§ß§Ú§Û §¡ §Ö§ã§Ý§Ú §å §Ñ§Ó§ä§à§â§Ñ §Ö§ã§ä§î §ã§Ó§ñ§Ù§î §ã §Ü§Ñ§â§ä§Ú§ß§Ü§à§Û-§Ñ§Ó§Ñ§ä§Ñ§â§Ü§à§Û? $posts->fetchRelations('author', 'picture'); §¹§ä§à §à§Ù§ß§Ñ§é§Ñ§Ö§ä, §é§ä§à §á§Ö§â§Ö§Õ §ä§Ö§Þ, §Ü§Ñ§Ü "§â§Ñ§ã§á§Ú§ç§Ñ§ä§î" §Ó§ã§Ö§ç §Ñ§Ó§ä§à§â§à§Ó §á§à §á§à§ã§ä§Ñ§Þ, §å §á§à§Ý§å§é§Ö§ß§ß§à§Û §Ü§à§Ý§Ý§Ö§Ü§è§Ú§Ú §Ñ§Ó§ä§à§â§à§Ó §Ò§å§Õ§Ö§ä §Ó§í§Ù§Ó§Ñ§ß §Þ§Ö§ä§à§Õ: $authors->fetchRelations('picture');
  • 35. §¬§Ñ§ã§Ü§Ñ§Õ§ß§í§Ö §à§á§Ö§â§Ñ§è§Ú§Ú §µ §à§ä§ß§à§ê§Ö§ß§Ú§Û §Þ§à§Ø§ß§à §á§â§à§á§Ú§ã§Ñ§ä§î §Õ§Ö§Û§ã§ä§Ó§Ú§Ö, §Ü§à§ä§à§â§à§Ö §Ò§å§Õ§Ö§ä §Ó§í§á§à§Ý§ß§ñ§ä§î§ã§ñ §á§â§Ú §å§Õ§Ñ§Ý§Ö§ß§Ú§Ú §Þ§à§Õ§Ö§Ý§Ú onDelete: ? CASCADE - §å§Õ§Ñ§Ý§Ú§ä§î §Ó§ã§Ö §ã§Ó§ñ§Ù§Ñ§ß§ß§í§Ö §Ù§Ñ§Ó§Ú§ã§Ú§Þ§í§Ö §Þ§à§Õ§Ö§Ý§Ú ? SET NULL - §à§é§Ú§ã§ä§Ú§ä§î §Ù§ß§Ñ§é§Ö§ß§Ú§ñ §Ó§ß§Ö§ê§ß§Ú§ç §Ü§Ý§ð§é§Ö§Û §¿§ä§à §á§à§Ù§Ó§à§Ý§ñ§Ö§ä §ã§à§ç§â§Ñ§ß§ñ§ä§î §è§Ö§Ý§à§ã§ä§ß§à§ã§ä§î §ã§Ó§ñ§Ù§Ö§Û §Ó§ß§å§ä§â§Ú §ß§Ñ§ê§Ö§Û §ã§Ú§ã§ä§Ö§Þ§í.
  • 36. §¨§Ú§Ù§ß§î §Ò§Ö§Ù Join'§à§Ó §¬§Ñ§Ü §ã§Õ§Ö§Ý§Ñ§ä§î §Ó§í§Ò§à§â§Ü§å §á§à§ã§ä§à§Ó, §ß§Ñ§á§Ú§ã§Ñ§ß§ß§í§ç §Ø§Ö§ß§ë§Ú§ß§Ñ§Þ§Ú, §Ö§ã§Ý§Ú §á§à§ã§ä§í §Ú§ã§á§à§Ý§î§Ù§å§ð§ä §à§Õ§ß§à §ç§â§Ñ§ß§Ú§Ý§Ú§ë§Ö, §Ñ §Ñ§Ó§ä§à§â§í §Õ§â§å§Ô§à§Ö, §Ú §ß§Ö§ä §Ó§à§Ù§Þ§à§Ø§ß§à§ã§ä§Ú §ã§Õ§Ö§Ý§Ñ§ä§î join? §ª§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î sphinx. ? §³§à§Ù§Õ§Ñ§Ö§Þ §Ú§ß§Õ§Ö§Ü§ã §Ó §ã§æ§Ú§ß§Ü§ã§Ö §Õ§Ý§ñ §ä§Ñ§Ü§à§Ô§à §â§à§Õ§Ñ §Ó§í§Ò§à§â§Ü§Ú. ? §ª§ß§Õ§Ö§Ü§ã§Ú§â§å§Ö§Þ §Õ§Ñ§ß§ß§í§Ö. ? §³§à§Ù§Õ§Ñ§Ö§Þ sphinx §Õ§Ö§Ü§à§â§Ñ§ä§à§â ? §¥§Ö§Ü§à§â§Ñ§ä§à§â §Ú§ë§Ö§ä id §Õ§à§Ü§å§Þ§Ö§ß§ä§à§Ó, §å§Õ§à§Ó§Ý§Ö§ä§Ó§à§â§ñ§ð§ë§Ú§ç §á§à§Ú§ã§Ü§à§Ó§à§Þ§å §Ù§Ñ§á§â§à§ã§å. §ª §á§à §ï§ä§à§Þ §ã§á§Ú§ã§Ü§å id §Þ§Ñ§á§á§Ö§â §Ó§à§Ù§Ó§â§Ñ§ë§Ñ§Ö§ä §Ü§à§Ý§Ý§Ö§Ü§è§Ú§ð §ã §â§Ö§Ù§å§Ý§î§ä§Ñ§ä§à§Þ.
  • 37. §¹§ä§à §Õ§Ñ§Ý§à §Ó§ß§Ö§Õ§â§Ö§ß§Ú§Ö ORM ? §³§å§ë§Ö§ã§ä§Ó§Ö§ß§ß§à§Ö §å§ã§Ü§à§â§Ö§ß§Ú§Ö §â§Ñ§Ù§â§Ñ§Ò§à§ä§Ü§Ú ? §£§â§Ö§Þ§ñ §Ó§ç§à§Ø§Õ§Ö§ß§Ú§ñ §Ó §é§å§Ø§à§Û §Ü§à§Õ §Ù§ß§Ñ§é§Ú§ä§Ö§Ý§î§ß§à §å§Þ§Ö§ß§î§ê§Ú§Ý§à§ã§î ? §ª§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ß§Ú§Ö Domain Driven Design §á§à§Ù§Ó§à§Ý§ñ§Ö§ä §Ô§à§Ó§à§â§Ú§ä§î §ß§Ñ §ñ§Ù§í§Ü§Ö §á§â§Ö§Õ§Þ§Ö§ä§ß§à§Û §à§Ò§Ý§Ñ§ã§ä§Ú, §é§ä§à §á§à§Ó§í§ê§Ñ§Ö§ä §é§Ú§ä§Ñ§Ö§Þ§à§ã§ä§î §Ü§à§Õ§Ñ ? §­§à§Ô§Ú§Ü§Ñ §á§â§Ú§Ý§à§Ø§Ö§ß§Ú§ñ §Ó§í§ß§Ö§ã§Ö§ß§Ñ §Ó §à§ä§Õ§Ö§Ý§î§ß§í§Û §ã§Ý§à§Û §ã§Ö§â§Ó§Ú§ã§à§Ó. §¹§ä§à §á§à§Ù§Ó§à§Ý§ñ§Ö§ä §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ä§î §Ö§Ö §ß§Ö §ä§à§Ý§î§Ü§à §Ó MVC, §ß§à §Ú §Ó CLI, §ß§Ñ§á§â§Ú§Þ§Ö§â. ? §²§Ñ§Ù§Þ§Ö§â §ï§Ü§ê§Ö§ß§à§Ó §Ó §Ü§à§ß§ä§â§à§Ý§Ý§Ö§â§Ñ§ç §ã§à§Ü§â§Ñ§ä§Ú§Ý§ã§ñ §Õ§à 10 §ã§ä§â§à§Ü.
  • 38. §¢§å§Õ§Ö§ä §Ý§Ú open source? §¢§å§Õ§Ö§ä, §ß§à §á§à§Ù§Ø§Ö )