@@ -29,7 +29,7 @@ |
||
29 | 29 | <div class="control-group"> |
30 | 30 | <label class="control-label">Store dates / timestamps in UTC:</label> |
31 | 31 | <div class="controls"> |
32 | - <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input> |
|
32 | + <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input> |
|
33 | 33 | <span class="help-block">Select this option if you want timestamps to be stored in UTC. |
34 | 34 | If your application supports several time zones, you should select this option to store all dates in |
35 | 35 | the same time zone.</span> |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $columnName |
86 | 86 | * @param array<string> $values |
87 | 87 | */ |
88 | - public function __construct($tableName=null, $columnName=null, $values=array()) { |
|
88 | + public function __construct($tableName = null, $columnName = null, $values = array()) { |
|
89 | 89 | $this->tableName = $tableName; |
90 | 90 | $this->columnName = $columnName; |
91 | 91 | $this->values = $values; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - return $this->tableName.'.'.$this->columnName.' IN ('.implode(',',$values_sql).")"; |
|
120 | + return $this->tableName.'.'.$this->columnName.' IN ('.implode(',', $values_sql).")"; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -86,7 +86,7 @@ |
||
86 | 86 | * @param string $columnName |
87 | 87 | * @param string $order |
88 | 88 | */ |
89 | - public function __construct($tableName=null, $columnName=null, $order=null) { |
|
89 | + public function __construct($tableName = null, $columnName = null, $order = null) { |
|
90 | 90 | $this->tableName = $tableName; |
91 | 91 | $this->columnName = $columnName; |
92 | 92 | $this->order = $order; |
@@ -84,7 +84,6 @@ |
||
84 | 84 | * |
85 | 85 | * @param string $tableName |
86 | 86 | * @param string $columnName |
87 | - * @param string $value |
|
88 | 87 | */ |
89 | 88 | public function __construct($tableName=null, $columnName=null, $order=null) { |
90 | 89 | $this->tableName = $tableName; |
@@ -1,8 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Mouf\Database\TDBM\Filters; |
3 | 3 | |
4 | -use Mouf\Database\DBConnection\ConnectionInterface; |
|
5 | - |
|
6 | 4 | /* |
7 | 5 | Copyright (C) 2006-2011 David Négrier - THE CODING MACHINE |
8 | 6 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * |
60 | 60 | * @param FilterInterface $filter |
61 | 61 | */ |
62 | - public function __construct($filter=null) { |
|
62 | + public function __construct($filter = null) { |
|
63 | 63 | $this->filter = $filter; |
64 | 64 | } |
65 | 65 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param string $sqlString |
64 | 64 | */ |
65 | - public function __construct($sqlString=null) { |
|
65 | + public function __construct($sqlString = null) { |
|
66 | 66 | $this->sqlString = $sqlString; |
67 | 67 | } |
68 | 68 | |
@@ -95,32 +95,32 @@ discard block |
||
95 | 95 | // First, let's remove all the stuff in quotes: |
96 | 96 | |
97 | 97 | // Let's remove all the \' found |
98 | - $work_str = str_replace("\\'",'',$this->sqlString); |
|
98 | + $work_str = str_replace("\\'", '', $this->sqlString); |
|
99 | 99 | // Now, let's split the string using ' |
100 | 100 | $work_table = explode("'", $work_str); |
101 | 101 | |
102 | - if (count($work_table)==0) |
|
102 | + if (count($work_table) == 0) |
|
103 | 103 | return ''; |
104 | 104 | |
105 | 105 | // if we start with a ', let's remove the first text |
106 | - if (strstr($work_str,"'")===0) |
|
106 | + if (strstr($work_str, "'") === 0) |
|
107 | 107 | array_shift($work_table); |
108 | 108 | |
109 | - if (count($work_table)==0) |
|
109 | + if (count($work_table) == 0) |
|
110 | 110 | return ''; |
111 | 111 | |
112 | 112 | // Now, let's take only the stuff outside the quotes. |
113 | 113 | $work_str2 = ''; |
114 | 114 | |
115 | - $i=0; |
|
115 | + $i = 0; |
|
116 | 116 | foreach ($work_table as $str_fragment) { |
117 | - if (($i % 2) == 0) |
|
117 | + if (($i%2) == 0) |
|
118 | 118 | $work_str2 .= $str_fragment.' '; |
119 | 119 | $i++; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // Now, let's run a regexp to find all the strings matching the pattern xxx.yyy |
123 | - preg_match_all('/([a-zA-Z_](?:[a-zA-Z0-9_]*))\.(?:[a-zA-Z_](?:[a-zA-Z0-9_]*))/', $work_str2,$capture_result); |
|
123 | + preg_match_all('/([a-zA-Z_](?:[a-zA-Z0-9_]*))\.(?:[a-zA-Z_](?:[a-zA-Z0-9_]*))/', $work_str2, $capture_result); |
|
124 | 124 | |
125 | 125 | $tables_used = $capture_result[1]; |
126 | 126 | // remove doubles: |
@@ -99,23 +99,27 @@ |
||
99 | 99 | // Now, let's split the string using ' |
100 | 100 | $work_table = explode("'", $work_str); |
101 | 101 | |
102 | - if (count($work_table)==0) |
|
103 | - return ''; |
|
102 | + if (count($work_table)==0) { |
|
103 | + return ''; |
|
104 | + } |
|
104 | 105 | |
105 | 106 | // if we start with a ', let's remove the first text |
106 | - if (strstr($work_str,"'")===0) |
|
107 | - array_shift($work_table); |
|
107 | + if (strstr($work_str,"'")===0) { |
|
108 | + array_shift($work_table); |
|
109 | + } |
|
108 | 110 | |
109 | - if (count($work_table)==0) |
|
110 | - return ''; |
|
111 | + if (count($work_table)==0) { |
|
112 | + return ''; |
|
113 | + } |
|
111 | 114 | |
112 | 115 | // Now, let's take only the stuff outside the quotes. |
113 | 116 | $work_str2 = ''; |
114 | 117 | |
115 | 118 | $i=0; |
116 | 119 | foreach ($work_table as $str_fragment) { |
117 | - if (($i % 2) == 0) |
|
118 | - $work_str2 .= $str_fragment.' '; |
|
120 | + if (($i % 2) == 0) { |
|
121 | + $work_str2 .= $str_fragment.' '; |
|
122 | + } |
|
119 | 123 | $i++; |
120 | 124 | } |
121 | 125 |
@@ -101,7 +101,7 @@ |
||
101 | 101 | * @param string $value1 |
102 | 102 | * @param string $value2 |
103 | 103 | */ |
104 | - public function __construct($tableName=null, $columnName=null, $value1=null, $value2=null) { |
|
104 | + public function __construct($tableName = null, $columnName = null, $value1 = null, $value2 = null) { |
|
105 | 105 | $this->tableName = $tableName; |
106 | 106 | $this->columnName = $columnName; |
107 | 107 | $this->value1 = $value1; |
@@ -98,7 +98,7 @@ |
||
98 | 98 | * |
99 | 99 | * @param string $tableName |
100 | 100 | * @param string $columnName |
101 | - * @param string $value |
|
101 | + * @param string $value1 |
|
102 | 102 | */ |
103 | 103 | public function __construct($tableName=null, $columnName=null, $value1=null, $value2=null) { |
104 | 104 | $this->tableName = $tableName; |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Mouf\Database\TDBM\Filters; |
3 | 3 | |
4 | 4 | use Mouf\Database\TDBM\TDBMException; |
5 | - |
|
6 | 5 | use Mouf\Database\DBConnection\ConnectionInterface; |
7 | 6 | |
8 | 7 | /* |
@@ -85,7 +85,7 @@ |
||
85 | 85 | * @param string $columnName |
86 | 86 | * @param string $value |
87 | 87 | */ |
88 | - public function __construct($tableName=null, $columnName=null, $value=null) { |
|
88 | + public function __construct($tableName = null, $columnName = null, $value = null) { |
|
89 | 89 | $this->tableName = $tableName; |
90 | 90 | $this->columnName = $columnName; |
91 | 91 | $this->value = $value; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function explainAmbiguity() { |
20 | 20 | $all_paths = $this->getAllPossiblePaths(); |
21 | 21 | |
22 | - $i=0; |
|
22 | + $i = 0; |
|
23 | 23 | $width_px = 0; |
24 | 24 | $height_px = 0; |
25 | 25 | $global_height_px = 0; |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | private static function getAllPossiblePathsRec($sub_table_paths) |
52 | 52 | { |
53 | - if (count($sub_table_paths)==0) |
|
53 | + if (count($sub_table_paths) == 0) |
|
54 | 54 | return array(); |
55 | 55 | |
56 | 56 | $table_path = array_shift($sub_table_paths); |
57 | - $possible_sub_paths = AmbiguityException::getAllPossiblePathsRec($sub_table_paths); |
|
57 | + $possible_sub_paths = AmbiguityException::getAllPossiblePathsRec($sub_table_paths); |
|
58 | 58 | $return_table_paths = array(); |
59 | 59 | foreach ($table_path['paths'] as $path) { |
60 | 60 | if (count($possible_sub_paths)>0) |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | private static function getAllPossiblePathsRec($sub_table_paths) |
52 | 52 | { |
53 | - if (count($sub_table_paths)==0) |
|
54 | - return array(); |
|
53 | + if (count($sub_table_paths)==0) { |
|
54 | + return array(); |
|
55 | + } |
|
55 | 56 | |
56 | 57 | $table_path = array_shift($sub_table_paths); |
57 | 58 | $possible_sub_paths = AmbiguityException::getAllPossiblePathsRec($sub_table_paths); |
@@ -63,9 +64,9 @@ discard block |
||
63 | 64 | { |
64 | 65 | $return_table_paths[] = array_merge(array(array('paths'=>array($path))), $possible_sub_path); |
65 | 66 | } |
67 | + } else { |
|
68 | + $return_table_paths[] = array(array('paths'=>array($path))); |
|
66 | 69 | } |
67 | - else |
|
68 | - $return_table_paths[] = array(array('paths'=>array($path))); |
|
69 | 70 | } |
70 | 71 | return $return_table_paths; |
71 | 72 | } |
@@ -170,6 +170,9 @@ |
||
170 | 170 | |
171 | 171 | protected $errorMsg; |
172 | 172 | |
173 | + /** |
|
174 | + * @param string $msg |
|
175 | + */ |
|
173 | 176 | private function displayErrorMsg($msg) { |
174 | 177 | $this->errorMsg = $msg; |
175 | 178 | $this->content->addFile(dirname(__FILE__)."/../../../../views/installError.php", $this); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | class TDBMObjectArray extends \ArrayObject implements \JsonSerializable { |
29 | 29 | public function __get($var) { |
30 | 30 | $cnt = count($this); |
31 | - if ($cnt==1) |
|
31 | + if ($cnt == 1) |
|
32 | 32 | { |
33 | 33 | return $this[0]->__get($var); |
34 | 34 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function __set($var, $value) { |
46 | 46 | $cnt = count($this); |
47 | - if ($cnt==1) |
|
47 | + if ($cnt == 1) |
|
48 | 48 | { |
49 | 49 | return $this[0]->__set($var, $value); |
50 | 50 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function __call($func_name, $values) { |
71 | 71 | |
72 | - if (strpos($func_name,"getarray_") === 0) { |
|
72 | + if (strpos($func_name, "getarray_") === 0) { |
|
73 | 73 | $column = substr($func_name, 9); |
74 | 74 | return $this->getarray($column); |
75 | - } elseif (strpos($func_name,"setarray_") === 0) { |
|
75 | + } elseif (strpos($func_name, "setarray_") === 0) { |
|
76 | 76 | $column = substr($func_name, 9); |
77 | 77 | return $this->setarray($column, $values[0]); |
78 | - } elseif (count($this)==1) { |
|
78 | + } elseif (count($this) == 1) { |
|
79 | 79 | $this[0]->__call($func_name, $values); |
80 | 80 | } |
81 | 81 | else |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - public function jsonSerialize(){ |
|
102 | + public function jsonSerialize() { |
|
103 | 103 | return (array) $this; |
104 | 104 | } |
105 | 105 | } |
@@ -31,12 +31,10 @@ discard block |
||
31 | 31 | if ($cnt==1) |
32 | 32 | { |
33 | 33 | return $this[0]->__get($var); |
34 | - } |
|
35 | - elseif ($cnt>1) |
|
34 | + } elseif ($cnt>1) |
|
36 | 35 | { |
37 | 36 | throw new TDBMException('Array contains many objects! Use getarray_'.$var.' to retrieve an array of '.$var); |
38 | - } |
|
39 | - else |
|
37 | + } else |
|
40 | 38 | { |
41 | 39 | throw new TDBMException('Array contains no objects'); |
42 | 40 | } |
@@ -47,12 +45,10 @@ discard block |
||
47 | 45 | if ($cnt==1) |
48 | 46 | { |
49 | 47 | return $this[0]->__set($var, $value); |
50 | - } |
|
51 | - elseif ($cnt>1) |
|
48 | + } elseif ($cnt>1) |
|
52 | 49 | { |
53 | 50 | throw new TDBMException('Array contains many objects! Use setarray_'.$var.' to set the array of '.$var); |
54 | - } |
|
55 | - else |
|
51 | + } else |
|
56 | 52 | { |
57 | 53 | throw new TDBMException('Array contains no objects'); |
58 | 54 | } |
@@ -77,8 +73,7 @@ discard block |
||
77 | 73 | return $this->setarray($column, $values[0]); |
78 | 74 | } elseif (count($this)==1) { |
79 | 75 | $this[0]->__call($func_name, $values); |
80 | - } |
|
81 | - else |
|
76 | + } else |
|
82 | 77 | { |
83 | 78 | throw new TDBMException("Method ".$func_name." not found"); |
84 | 79 | } |
@@ -84,6 +84,9 @@ discard block |
||
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | + /** |
|
88 | + * @param string $column |
|
89 | + */ |
|
87 | 90 | private function getarray($column) { |
88 | 91 | $arr = array(); |
89 | 92 | foreach ($this as $object) { |
@@ -92,6 +95,9 @@ discard block |
||
92 | 95 | return $arr; |
93 | 96 | } |
94 | 97 | |
98 | + /** |
|
99 | + * @param string $column |
|
100 | + */ |
|
95 | 101 | private function setarray($column, $value) { |
96 | 102 | foreach ($this as $object) { |
97 | 103 | $object->__set($column, $value); |