Rev 53 | Rev 55 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 53 | Rev 54 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | /**
|
15 | /**
|
16 | * The <code>Table</code> for instances of this model
|
16 | * The <code>Table</code> for instances of this model
|
17 | *
|
17 | *
|
18 | * @type Table|string
|
18 | * @type Table|string
|
19 | */
|
19 | */
|
20 | protected $_persistentTable; |
20 | protected static $_persistentTable; |
21 | 21 | ||
22 | /**
|
22 | /**
|
23 | * The name(s) of the property or properties whose value(s)
|
23 | * The name(s) of the property or properties whose value(s)
|
24 | * identify this object in the <code>Table</code>. They are
|
24 | * identify this object in the <code>Table</code>. They are
|
25 | * used for comparing against the primary key column(s) of
|
25 | * used for comparing against the primary key column(s) of
|
Line 55... | Line 55... | ||
55 | parent::__construct($data, $mapping); |
55 | parent::__construct($data, $mapping); |
56 | }
|
56 | }
|
57 | 57 | ||
58 | public function getPersistentTable () |
58 | public function getPersistentTable () |
59 | {
|
59 | {
|
- | 60 | $class = \get_class($this); |
|
60 | if (is_string($this->_persistentTable)) |
61 | if (\is_string($class::$_persistentTable)) |
61 | {
|
62 | {
|
62 | /* Call setter to convert to Table */
|
63 | /* Call setter to convert to Table */
|
63 | $this->persistentTable = $this->_persistentTable; |
64 | $this->setPersistentTable($class::$_persistentTable); |
64 | }
|
65 | }
|
65 | 66 | ||
66 | return $this->_persistentTable; |
67 | return $class::$_persistentTable; |
67 | }
|
68 | }
|
68 | 69 | ||
69 | public function setPersistentTable ($value) |
70 | public function setPersistentTable ($value) |
70 | {
|
71 | {
|
- | 72 | $class = \get_class($this); |
|
71 | if ($value instanceof Table) |
73 | if ($value instanceof Table) |
72 | {
|
74 | {
|
73 | $this->_persistentTable = $value; |
75 | $class::$_persistentTable = $value; |
74 | }
|
76 | }
|
75 | else
|
77 | else
|
76 | {
|
78 | {
|
77 | $table = new $value(); |
79 | $table = new $value(); |
78 | if (!($table instanceof Db\Table)) |
80 | if (!($table instanceof Db\Table)) |
Line 81... | Line 83... | ||
81 | 'Parameter does not specify a subclass of \\PointedEars\\PHPX\\Table: '
|
83 | 'Parameter does not specify a subclass of \\PointedEars\\PHPX\\Table: '
|
82 | . $value |
84 | . $value |
83 | ); |
85 | ); |
84 | }
|
86 | }
|
85 | 87 | ||
86 | $this->_persistentTable = $table; |
88 | $class::$_persistentTable = $table; |
87 | }
|
89 | }
|
88 | }
|
90 | }
|
89 | 91 | ||
90 | /**
|
92 | /**
|
91 | * Returns an array for database queries containing the
|
93 | * Returns an array for database queries containing the
|
Line 128... | Line 130... | ||
128 | * This object filled with missing data, or <code>null</code>
|
130 | * This object filled with missing data, or <code>null</code>
|
129 | * if there is no data for this object
|
131 | * if there is no data for this object
|
130 | */
|
132 | */
|
131 | public function find () |
133 | public function find () |
132 | {
|
134 | {
|
- | 135 | $class = \get_class($this); |
|
133 | $result = $this->persistentTable->find($this->{$this->_persistentId}); |
136 | $result = $this->persistentTable->find($this->{$this->_persistentId}); |
134 | if ($result) |
137 | if ($result) |
135 | {
|
138 | {
|
136 | return $this->map($result); |
139 | return $this->map($result); |
137 | }
|
140 | }
|