-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoviesToCategories.php
110 lines (107 loc) · 3.55 KB
/
MoviesToCategories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
Copyright (C) 2008 Jesse Hogan <jessehogan0@gmail.com>
All rights reserverd
*/
// vim: set et ts=4 sw=4 fdm=marker:
require_once("Business_Objects.php");
require_once("Categories.php");
class MovieToCategories extends Business_Collection_Base {
var $_excludeOnUpdate;
function AddCategory(&$movie, &$category){
@fprintf(STDOUT, "DBG9 %s/%s\n", __CLASS__, __FUNCTION__); #SED_DELETE_ON_ROLL
$movieToCategory = new MovieToCategory();
$movieToCategory->Movie($movie);
$movieToCategory->Category($category);
$movieToCategory->_collection = &$this;
$this->_collection[] = $movieToCategory;
}
function ExcludeOnUpdate($bo=null){
if($bo == null){
return strtolower($this->_excludeOnUpdate);
}else{
$this->_excludeOnUpdate = get_class($bo);
}
}
}
class MovieToCategory extends Business_Base {
var $_category;
var $_movie;
function BO($id=null)
{
$this->Business_Base($id);
}
function &Movie(&$value=null){
if ($value == null){
return $this->_movie;
}else{
$this->_movie = &$value;
}
}
function Category(&$value=null){
@fprintf(STDOUT, "DBG9 %s/%s\n", __CLASS__, __FUNCTION__); #SED_DELETE_ON_ROLL
if ($value == null){
if (!isset($this->_category)){
@fprintf(STDOUT, "DBG9 %s/%sLoading Category id:%s\n", __CLASS__, __FUNCTION__, $this->CategoryID()); #SED_DELETE_ON_ROLL
$this->_category =
new Category($this->CategoryID());
}
return $this->_category;
}else{
$this->_category = &$value;
}
}
function MovieID($value=null)
{
if ($value == null && isset($this->_movie)){
if(!$this->_movie->IsNew()){
return $this->_movie->ID();
}
}
return $this->SetVar(__FUNCTION__, $value);
}
function CategoryID($value=null)
{
if ($value == null && isset($this->_category)){
if(!$this->_category->IsNew()){
return $this->_category->ID();
}
}
return $this->SetVar(__FUNCTION__, $value);
}
function DiscoverTableDefinition(){
/*
AddMap( $method, $field, $type, $unsigned,
$not_null, $default, $length, $autoincrement);
*/
$this->AddMap('ID', 'id', 'integer', true, true, 0, 4, 1);
$this->AddIndex('MovieID', 'movieID, asc, 0');
$this->AddMap('MovieID', 'movieID', 'integer', true, true, 0, 4, 0);
$this->AddMap('CategoryID', 'categoryID', 'integer', true, true, 0, 4, 0);
}
function Table(){
return "movie_to_category";
}
function &_BrokenRules(){
$brs = new Broken_Rules();
return $brs;
}
function Update(){
@fprintf(STDOUT, "DBG9 %s/%s\n", __CLASS__, __FUNCTION__); #SED_DELETE_ON_ROLL
$col = $this->Collection();
if ($col->ExcludeOnUpdate() != 'movie'){
if (isset($this->_movie)){
@fprintf(STDOUT, "DBG9 %s/%s Updating movie\n", __CLASS__, __FUNCTION__); #SED_DELETE_ON_ROLL
$this->_movie->Update();
}
}
if ($col->ExcludeOnUpdate() != 'category'){
if (isset($this->_category)){
@fprintf(STDOUT, "DBG9 %s/%s Updating category\n", __CLASS__, __FUNCTION__); #SED_DELETE_ON_ROLL
$this->_category->Update();
}
}
parent::Update();
}
}
?>