Subversion Repositories PHPX

Rev

Rev 27 | Rev 51 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
27 PointedEar 1
<?php
2
 
29 PointedEar 3
require_once __DIR__ . '/AbstractModel.php';
4
 
27 PointedEar 5
/**
6
* Abstract model class
7
*
8
* Provides basic setters and getters for protected/private properties
9
* and a constructor to initialize properties using setters and getters.
10
*
11
* @author Thomas Lahn
12
*/
13
abstract class Model extends AbstractModel
14
{
15
  /* ORM */
16
  const persistentPrimaryKey = 'id';
17
 
18
  /**
19
   * @var Adapter
20
   */
21
  protected static $persistentAdapter;
22
 
23
  /**
24
   * Creates a new model object
25
   *
26
   * @param array $data     Initialization data (optional)
27
   * @param array $mapping  Mapping for initialization data (optional)
28
   */
29
  public function __construct(array $data = null, array $mapping = null)
30
  {
31
    $this->setAdapter();
32
 
33
    parent::__construct($data, $mapping);
34
  }
35
 
36
  /**
37
   * Finds the record for the model object in a database, and fills the object
38
   * with missing data
39
   * @see Adapter::find(Model)
40
   */
41
  public function find()
42
  {
43
    $class = get_class($this);
44
    return $class::$persistentAdapter->find($this);
45
  }
46
}