1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jovis\DatabaseModel; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class Movie extends \Jovis\DatabaseModel\CDatabaseModel |
8
|
|
|
{ |
9
|
|
|
|
10
|
2 |
|
public function init() |
11
|
|
|
{ |
12
|
2 |
|
$this->db->dropTableIfExists('movie') |
|
|
|
|
13
|
2 |
|
->execute(); |
14
|
|
|
|
15
|
2 |
|
$this->db->createTable( |
|
|
|
|
16
|
2 |
|
'movie', |
17
|
|
|
[ |
18
|
2 |
|
'id' => ['integer', 'primary key', 'not null', 'auto_increment'], |
19
|
2 |
|
'title' => ['varchar(100)', 'not null'], |
20
|
2 |
|
'director' => ['varchar(100)'], |
21
|
2 |
|
'length' => ['integer'], |
22
|
2 |
|
'year' => ['integer', 'not null'], |
23
|
2 |
|
]); |
24
|
|
|
|
25
|
2 |
|
$this->db->execute(); |
|
|
|
|
26
|
|
|
|
27
|
|
|
|
28
|
2 |
|
$this->db->insert( |
|
|
|
|
29
|
2 |
|
'movie', |
30
|
2 |
|
['title', 'director', 'length', 'year'] |
31
|
2 |
|
); |
32
|
|
|
|
33
|
2 |
|
$this->db->execute(['Kalles drömmar', 'Gustav Andersson', '120', '1977']); |
|
|
|
|
34
|
|
|
|
35
|
2 |
|
$this->db->insert( |
|
|
|
|
36
|
2 |
|
'movie', |
37
|
2 |
|
['title', 'director', 'length', 'year'] |
38
|
2 |
|
); |
39
|
|
|
|
40
|
2 |
|
$this->db->execute(['Gustavs drömmar', 'Kalle Andersson', '101', '2007']); |
|
|
|
|
41
|
|
|
|
42
|
2 |
|
$this->db->insert( |
|
|
|
|
43
|
2 |
|
'movie', |
44
|
2 |
|
['title', 'director', 'length', 'year'] |
45
|
2 |
|
); |
46
|
|
|
|
47
|
2 |
|
$this->db->execute(['Mammas drömmar', 'Johanna Andersson', '25', '2010']); |
|
|
|
|
48
|
|
|
|
49
|
2 |
|
$this->db->insert( |
|
|
|
|
50
|
2 |
|
'movie', |
51
|
2 |
|
['title', 'director', 'length', 'year'] |
52
|
2 |
|
); |
53
|
|
|
|
54
|
2 |
|
$this->db->execute(['Goda kakor', 'Hannes Andersson', '110', '1954']); |
|
|
|
|
55
|
|
|
|
56
|
2 |
|
} |
57
|
|
|
} |
58
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.