@@ -92,8 +92,9 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function setUpdateInterval($updateInterval) |
94 | 94 | { |
95 | - if ($updateInterval <= 0) |
|
96 | - throw new \RuntimeException('Invalid update interval specified'); |
|
95 | + if ($updateInterval <= 0) { |
|
96 | + throw new \RuntimeException('Invalid update interval specified'); |
|
97 | + } |
|
97 | 98 | |
98 | 99 | $this->_updateInterval = $updateInterval; |
99 | 100 | } |
@@ -133,8 +134,9 @@ discard block |
||
133 | 134 | */ |
134 | 135 | public function setListenPort($listenPort) |
135 | 136 | { |
136 | - if ($listenPort < 1 || $listenPort > 65535) |
|
137 | - throw new \RuntimeException('Invalid port specified'); |
|
137 | + if ($listenPort < 1 || $listenPort > 65535) { |
|
138 | + throw new \RuntimeException('Invalid port specified'); |
|
139 | + } |
|
138 | 140 | |
139 | 141 | $this->_listenPort = $listenPort; |
140 | 142 | } |
@@ -142,7 +142,7 @@ |
||
142 | 142 | if ($configuration === false) |
143 | 143 | throw new InvalidConfigurationException('Failed to parse the specified configuration file'); |
144 | 144 | |
145 | - $instances = []; |
|
145 | + $instances = []; |
|
146 | 146 | |
147 | 147 | // Parse sections |
148 | 148 | foreach ($configuration as $section => $values) |
@@ -124,23 +124,26 @@ discard block |
||
124 | 124 | private function parseConfiguration(InputInterface $input) |
125 | 125 | { |
126 | 126 | // Check that the configuration file exists |
127 | - if (!file_exists($input->getArgument('configFile'))) |
|
128 | - throw new InvalidConfigurationException('The specified configuration file does not exist'); |
|
127 | + if (!file_exists($input->getArgument('configFile'))) { |
|
128 | + throw new InvalidConfigurationException('The specified configuration file does not exist'); |
|
129 | + } |
|
129 | 130 | |
130 | 131 | // Check that the database exists and is writable |
131 | 132 | $databasePath = $input->getArgument('databaseFile'); |
132 | 133 | |
133 | - if (!file_exists($databasePath)) |
|
134 | - throw new InvalidConfigurationException('The specified database path does not exist'); |
|
135 | - else if (!is_writable($databasePath)) |
|
136 | - throw new InvalidConfigurationException('The specified database path is not writable'); |
|
134 | + if (!file_exists($databasePath)) { |
|
135 | + throw new InvalidConfigurationException('The specified database path does not exist'); |
|
136 | + } else if (!is_writable($databasePath)) { |
|
137 | + throw new InvalidConfigurationException('The specified database path is not writable'); |
|
138 | + } |
|
137 | 139 | |
138 | 140 | // Parse the configuration file |
139 | 141 | $configuration = parse_ini_file($input->getArgument('configFile'), true); |
140 | 142 | |
141 | 143 | // Check that the file was parsed |
142 | - if ($configuration === false) |
|
143 | - throw new InvalidConfigurationException('Failed to parse the specified configuration file'); |
|
144 | + if ($configuration === false) { |
|
145 | + throw new InvalidConfigurationException('Failed to parse the specified configuration file'); |
|
146 | + } |
|
144 | 147 | |
145 | 148 | $instances = []; |
146 | 149 | |
@@ -157,8 +160,9 @@ discard block |
||
157 | 160 | $instance = new Instance($name, $address, $port); |
158 | 161 | |
159 | 162 | // Optionally set credentials |
160 | - if (isset($values['username']) && isset($values['password'])) |
|
161 | - $instance->setCredentials($values['username'], $values['password']); |
|
163 | + if (isset($values['username']) && isset($values['password'])) { |
|
164 | + $instance->setCredentials($values['username'], $values['password']); |
|
165 | + } |
|
162 | 166 | |
163 | 167 | $instances[] = $instance; |
164 | 168 | break; |
@@ -166,8 +170,9 @@ discard block |
||
166 | 170 | } |
167 | 171 | |
168 | 172 | // Validate the configuration. We need at least one instance. |
169 | - if (empty($instances)) |
|
170 | - throw new InvalidConfigurationException('No instances defined, you need to specify at least one instance'); |
|
173 | + if (empty($instances)) { |
|
174 | + throw new InvalidConfigurationException('No instances defined, you need to specify at least one instance'); |
|
175 | + } |
|
171 | 176 | |
172 | 177 | // Create the configuration object |
173 | 178 | $config = new Configuration($databasePath, $instances); |
@@ -196,8 +201,9 @@ discard block |
||
196 | 201 | */ |
197 | 202 | private static function getSectionType($section) |
198 | 203 | { |
199 | - if (substr($section, 0, 8) === 'instance') |
|
200 | - return Configuration::SECTION_TYPE_INSTANCE; |
|
204 | + if (substr($section, 0, 8) === 'instance') { |
|
205 | + return Configuration::SECTION_TYPE_INSTANCE; |
|
206 | + } |
|
201 | 207 | |
202 | 208 | throw new InvalidConfigurationException('Unknown section "' . $section . '"'); |
203 | 209 | } |
@@ -28,401 +28,401 @@ |
||
28 | 28 | */ |
29 | 29 | class ChannelTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ChannelTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'channel'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Channel'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Channel'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 3; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 3; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'channel.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'channel.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the name field |
|
86 | - */ |
|
87 | - const COL_NAME = 'channel.name'; |
|
88 | - |
|
89 | - /** |
|
90 | - * The default string format for model objects of the related table |
|
91 | - */ |
|
92 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | - |
|
94 | - /** |
|
95 | - * holds an array of fieldnames |
|
96 | - * |
|
97 | - * first dimension keys are the type constants |
|
98 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | - */ |
|
100 | - protected static $fieldNames = array ( |
|
101 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | - self::TYPE_COLNAME => array(ChannelTableMap::COL_ID, ChannelTableMap::COL_INSTANCE_NAME, ChannelTableMap::COL_NAME, ), |
|
104 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | - ); |
|
107 | - |
|
108 | - /** |
|
109 | - * holds an array of keys for quick access to the fieldnames array |
|
110 | - * |
|
111 | - * first dimension keys are the type constants |
|
112 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | - */ |
|
114 | - protected static $fieldKeys = array ( |
|
115 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | - self::TYPE_COLNAME => array(ChannelTableMap::COL_ID => 0, ChannelTableMap::COL_INSTANCE_NAME => 1, ChannelTableMap::COL_NAME => 2, ), |
|
118 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | - ); |
|
121 | - |
|
122 | - /** |
|
123 | - * Initialize the table attributes and columns |
|
124 | - * Relations are not initialized by this method since they are lazy loaded |
|
125 | - * |
|
126 | - * @return void |
|
127 | - * @throws PropelException |
|
128 | - */ |
|
129 | - public function initialize() |
|
130 | - { |
|
131 | - // attributes |
|
132 | - $this->setName('channel'); |
|
133 | - $this->setPhpName('Channel'); |
|
134 | - $this->setIdentifierQuoting(false); |
|
135 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\Channel'); |
|
136 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | - $this->setUseIdGenerator(true); |
|
138 | - // columns |
|
139 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | - $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | - } // initialize() |
|
143 | - |
|
144 | - /** |
|
145 | - * Build the RelationMap objects for this table relationships |
|
146 | - */ |
|
147 | - public function buildRelations() |
|
148 | - { |
|
149 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ChannelTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'channel'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Channel'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Channel'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 3; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 3; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'channel.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'channel.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the name field |
|
86 | + */ |
|
87 | + const COL_NAME = 'channel.name'; |
|
88 | + |
|
89 | + /** |
|
90 | + * The default string format for model objects of the related table |
|
91 | + */ |
|
92 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | + |
|
94 | + /** |
|
95 | + * holds an array of fieldnames |
|
96 | + * |
|
97 | + * first dimension keys are the type constants |
|
98 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | + */ |
|
100 | + protected static $fieldNames = array ( |
|
101 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | + self::TYPE_COLNAME => array(ChannelTableMap::COL_ID, ChannelTableMap::COL_INSTANCE_NAME, ChannelTableMap::COL_NAME, ), |
|
104 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | + ); |
|
107 | + |
|
108 | + /** |
|
109 | + * holds an array of keys for quick access to the fieldnames array |
|
110 | + * |
|
111 | + * first dimension keys are the type constants |
|
112 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | + */ |
|
114 | + protected static $fieldKeys = array ( |
|
115 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | + self::TYPE_COLNAME => array(ChannelTableMap::COL_ID => 0, ChannelTableMap::COL_INSTANCE_NAME => 1, ChannelTableMap::COL_NAME => 2, ), |
|
118 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | + ); |
|
121 | + |
|
122 | + /** |
|
123 | + * Initialize the table attributes and columns |
|
124 | + * Relations are not initialized by this method since they are lazy loaded |
|
125 | + * |
|
126 | + * @return void |
|
127 | + * @throws PropelException |
|
128 | + */ |
|
129 | + public function initialize() |
|
130 | + { |
|
131 | + // attributes |
|
132 | + $this->setName('channel'); |
|
133 | + $this->setPhpName('Channel'); |
|
134 | + $this->setIdentifierQuoting(false); |
|
135 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\Channel'); |
|
136 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | + $this->setUseIdGenerator(true); |
|
138 | + // columns |
|
139 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | + $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | + } // initialize() |
|
143 | + |
|
144 | + /** |
|
145 | + * Build the RelationMap objects for this table relationships |
|
146 | + */ |
|
147 | + public function buildRelations() |
|
148 | + { |
|
149 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
150 | 150 | 0 => |
151 | 151 | array ( |
152 | - 0 => ':instance_name', |
|
153 | - 1 => ':name', |
|
152 | + 0 => ':instance_name', |
|
153 | + 1 => ':name', |
|
154 | 154 | ), |
155 | 155 | ), null, null, null, false); |
156 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
156 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
157 | 157 | 0 => |
158 | 158 | array ( |
159 | - 0 => ':channel_id', |
|
160 | - 1 => ':id', |
|
159 | + 0 => ':channel_id', |
|
160 | + 1 => ':id', |
|
161 | 161 | ), |
162 | 162 | ), null, null, 'Subscriptions', false); |
163 | - } // buildRelations() |
|
164 | - |
|
165 | - /** |
|
166 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
167 | - * |
|
168 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
169 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
170 | - * |
|
171 | - * @param array $row resultset row. |
|
172 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
173 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
174 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
175 | - * |
|
176 | - * @return string The primary key hash of the row |
|
177 | - */ |
|
178 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
179 | - { |
|
180 | - // If the PK cannot be derived from the row, return NULL. |
|
181 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
182 | - return null; |
|
183 | - } |
|
184 | - |
|
185 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Retrieves the primary key from the DB resultset row |
|
190 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
191 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
192 | - * |
|
193 | - * @param array $row resultset row. |
|
194 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
195 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
196 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
197 | - * |
|
198 | - * @return mixed The primary key of the row |
|
199 | - */ |
|
200 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
201 | - { |
|
202 | - return (int) $row[ |
|
203 | - $indexType == TableMap::TYPE_NUM |
|
204 | - ? 0 + $offset |
|
205 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
206 | - ]; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * The class that the tableMap will make instances of. |
|
211 | - * |
|
212 | - * If $withPrefix is true, the returned path |
|
213 | - * uses a dot-path notation which is translated into a path |
|
214 | - * relative to a location on the PHP include_path. |
|
215 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
216 | - * |
|
217 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
218 | - * @return string path.to.ClassName |
|
219 | - */ |
|
220 | - public static function getOMClass($withPrefix = true) |
|
221 | - { |
|
222 | - return $withPrefix ? ChannelTableMap::CLASS_DEFAULT : ChannelTableMap::OM_CLASS; |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Populates an object of the default type or an object that inherit from the default. |
|
227 | - * |
|
228 | - * @param array $row row returned by DataFetcher->fetch(). |
|
229 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
230 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
163 | + } // buildRelations() |
|
164 | + |
|
165 | + /** |
|
166 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
167 | + * |
|
168 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
169 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
170 | + * |
|
171 | + * @param array $row resultset row. |
|
172 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
173 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
174 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
175 | + * |
|
176 | + * @return string The primary key hash of the row |
|
177 | + */ |
|
178 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
179 | + { |
|
180 | + // If the PK cannot be derived from the row, return NULL. |
|
181 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
182 | + return null; |
|
183 | + } |
|
184 | + |
|
185 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Retrieves the primary key from the DB resultset row |
|
190 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
191 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
192 | + * |
|
193 | + * @param array $row resultset row. |
|
194 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
195 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
196 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
197 | + * |
|
198 | + * @return mixed The primary key of the row |
|
199 | + */ |
|
200 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
201 | + { |
|
202 | + return (int) $row[ |
|
203 | + $indexType == TableMap::TYPE_NUM |
|
204 | + ? 0 + $offset |
|
205 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
206 | + ]; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * The class that the tableMap will make instances of. |
|
211 | + * |
|
212 | + * If $withPrefix is true, the returned path |
|
213 | + * uses a dot-path notation which is translated into a path |
|
214 | + * relative to a location on the PHP include_path. |
|
215 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
216 | + * |
|
217 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
218 | + * @return string path.to.ClassName |
|
219 | + */ |
|
220 | + public static function getOMClass($withPrefix = true) |
|
221 | + { |
|
222 | + return $withPrefix ? ChannelTableMap::CLASS_DEFAULT : ChannelTableMap::OM_CLASS; |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Populates an object of the default type or an object that inherit from the default. |
|
227 | + * |
|
228 | + * @param array $row row returned by DataFetcher->fetch(). |
|
229 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
230 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
231 | 231 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
232 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
233 | - * |
|
234 | - * @throws PropelException Any exceptions caught during processing will be |
|
235 | - * rethrown wrapped into a PropelException. |
|
236 | - * @return array (Channel object, last column rank) |
|
237 | - */ |
|
238 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
239 | - { |
|
240 | - $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
241 | - if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
242 | - // We no longer rehydrate the object, since this can cause data loss. |
|
243 | - // See http://www.propelorm.org/ticket/509 |
|
244 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
245 | - $col = $offset + ChannelTableMap::NUM_HYDRATE_COLUMNS; |
|
246 | - } else { |
|
247 | - $cls = ChannelTableMap::OM_CLASS; |
|
248 | - /** @var Channel $obj */ |
|
249 | - $obj = new $cls(); |
|
250 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
251 | - ChannelTableMap::addInstanceToPool($obj, $key); |
|
252 | - } |
|
253 | - |
|
254 | - return array($obj, $col); |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * The returned array will contain objects of the default type or |
|
259 | - * objects that inherit from the default. |
|
260 | - * |
|
261 | - * @param DataFetcherInterface $dataFetcher |
|
262 | - * @return array |
|
263 | - * @throws PropelException Any exceptions caught during processing will be |
|
264 | - * rethrown wrapped into a PropelException. |
|
265 | - */ |
|
266 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
267 | - { |
|
268 | - $results = array(); |
|
269 | - |
|
270 | - // set the class once to avoid overhead in the loop |
|
271 | - $cls = static::getOMClass(false); |
|
272 | - // populate the object(s) |
|
273 | - while ($row = $dataFetcher->fetch()) { |
|
274 | - $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
275 | - if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
276 | - // We no longer rehydrate the object, since this can cause data loss. |
|
277 | - // See http://www.propelorm.org/ticket/509 |
|
278 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
279 | - $results[] = $obj; |
|
280 | - } else { |
|
281 | - /** @var Channel $obj */ |
|
282 | - $obj = new $cls(); |
|
283 | - $obj->hydrate($row); |
|
284 | - $results[] = $obj; |
|
285 | - ChannelTableMap::addInstanceToPool($obj, $key); |
|
286 | - } // if key exists |
|
287 | - } |
|
288 | - |
|
289 | - return $results; |
|
290 | - } |
|
291 | - /** |
|
292 | - * Add all the columns needed to create a new object. |
|
293 | - * |
|
294 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
295 | - * XML schema will not be added to the select list and only loaded |
|
296 | - * on demand. |
|
297 | - * |
|
298 | - * @param Criteria $criteria object containing the columns to add. |
|
299 | - * @param string $alias optional table alias |
|
300 | - * @throws PropelException Any exceptions caught during processing will be |
|
301 | - * rethrown wrapped into a PropelException. |
|
302 | - */ |
|
303 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
304 | - { |
|
305 | - if (null === $alias) { |
|
306 | - $criteria->addSelectColumn(ChannelTableMap::COL_ID); |
|
307 | - $criteria->addSelectColumn(ChannelTableMap::COL_INSTANCE_NAME); |
|
308 | - $criteria->addSelectColumn(ChannelTableMap::COL_NAME); |
|
309 | - } else { |
|
310 | - $criteria->addSelectColumn($alias . '.id'); |
|
311 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
312 | - $criteria->addSelectColumn($alias . '.name'); |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Returns the TableMap related to this object. |
|
318 | - * This method is not needed for general use but a specific application could have a need. |
|
319 | - * @return TableMap |
|
320 | - * @throws PropelException Any exceptions caught during processing will be |
|
321 | - * rethrown wrapped into a PropelException. |
|
322 | - */ |
|
323 | - public static function getTableMap() |
|
324 | - { |
|
325 | - return Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME)->getTable(ChannelTableMap::TABLE_NAME); |
|
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Add a TableMap instance to the database for this tableMap class. |
|
330 | - */ |
|
331 | - public static function buildTableMap() |
|
332 | - { |
|
333 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME); |
|
334 | - if (!$dbMap->hasTable(ChannelTableMap::TABLE_NAME)) { |
|
335 | - $dbMap->addTableObject(new ChannelTableMap()); |
|
336 | - } |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * Performs a DELETE on the database, given a Channel or Criteria object OR a primary key value. |
|
341 | - * |
|
342 | - * @param mixed $values Criteria or Channel object or primary key or array of primary keys |
|
343 | - * which is used to create the DELETE statement |
|
344 | - * @param ConnectionInterface $con the connection to use |
|
345 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
346 | - * if supported by native driver or if emulated using Propel. |
|
347 | - * @throws PropelException Any exceptions caught during processing will be |
|
348 | - * rethrown wrapped into a PropelException. |
|
349 | - */ |
|
350 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
351 | - { |
|
352 | - if (null === $con) { |
|
353 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
354 | - } |
|
355 | - |
|
356 | - if ($values instanceof Criteria) { |
|
357 | - // rename for clarity |
|
358 | - $criteria = $values; |
|
359 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\Channel) { // it's a model object |
|
360 | - // create criteria based on pk values |
|
361 | - $criteria = $values->buildPkeyCriteria(); |
|
362 | - } else { // it's a primary key, or an array of pks |
|
363 | - $criteria = new Criteria(ChannelTableMap::DATABASE_NAME); |
|
364 | - $criteria->add(ChannelTableMap::COL_ID, (array) $values, Criteria::IN); |
|
365 | - } |
|
366 | - |
|
367 | - $query = ChannelQuery::create()->mergeWith($criteria); |
|
368 | - |
|
369 | - if ($values instanceof Criteria) { |
|
370 | - ChannelTableMap::clearInstancePool(); |
|
371 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
372 | - foreach ((array) $values as $singleval) { |
|
373 | - ChannelTableMap::removeInstanceFromPool($singleval); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - return $query->delete($con); |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Deletes all rows from the channel table. |
|
382 | - * |
|
383 | - * @param ConnectionInterface $con the connection to use |
|
384 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
385 | - */ |
|
386 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
387 | - { |
|
388 | - return ChannelQuery::create()->doDeleteAll($con); |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Performs an INSERT on the database, given a Channel or Criteria object. |
|
393 | - * |
|
394 | - * @param mixed $criteria Criteria or Channel object containing data that is used to create the INSERT statement. |
|
395 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
396 | - * @return mixed The new primary key. |
|
397 | - * @throws PropelException Any exceptions caught during processing will be |
|
398 | - * rethrown wrapped into a PropelException. |
|
399 | - */ |
|
400 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
401 | - { |
|
402 | - if (null === $con) { |
|
403 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
404 | - } |
|
405 | - |
|
406 | - if ($criteria instanceof Criteria) { |
|
407 | - $criteria = clone $criteria; // rename for clarity |
|
408 | - } else { |
|
409 | - $criteria = $criteria->buildCriteria(); // build Criteria from Channel object |
|
410 | - } |
|
411 | - |
|
412 | - if ($criteria->containsKey(ChannelTableMap::COL_ID) && $criteria->keyContainsValue(ChannelTableMap::COL_ID) ) { |
|
413 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ChannelTableMap::COL_ID.')'); |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - // Set the correct dbName |
|
418 | - $query = ChannelQuery::create()->mergeWith($criteria); |
|
419 | - |
|
420 | - // use transaction because $criteria could contain info |
|
421 | - // for more than one table (I guess, conceivably) |
|
422 | - return $con->transaction(function () use ($con, $query) { |
|
423 | - return $query->doInsert($con); |
|
424 | - }); |
|
425 | - } |
|
232 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
233 | + * |
|
234 | + * @throws PropelException Any exceptions caught during processing will be |
|
235 | + * rethrown wrapped into a PropelException. |
|
236 | + * @return array (Channel object, last column rank) |
|
237 | + */ |
|
238 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
239 | + { |
|
240 | + $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
241 | + if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
242 | + // We no longer rehydrate the object, since this can cause data loss. |
|
243 | + // See http://www.propelorm.org/ticket/509 |
|
244 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
245 | + $col = $offset + ChannelTableMap::NUM_HYDRATE_COLUMNS; |
|
246 | + } else { |
|
247 | + $cls = ChannelTableMap::OM_CLASS; |
|
248 | + /** @var Channel $obj */ |
|
249 | + $obj = new $cls(); |
|
250 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
251 | + ChannelTableMap::addInstanceToPool($obj, $key); |
|
252 | + } |
|
253 | + |
|
254 | + return array($obj, $col); |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * The returned array will contain objects of the default type or |
|
259 | + * objects that inherit from the default. |
|
260 | + * |
|
261 | + * @param DataFetcherInterface $dataFetcher |
|
262 | + * @return array |
|
263 | + * @throws PropelException Any exceptions caught during processing will be |
|
264 | + * rethrown wrapped into a PropelException. |
|
265 | + */ |
|
266 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
267 | + { |
|
268 | + $results = array(); |
|
269 | + |
|
270 | + // set the class once to avoid overhead in the loop |
|
271 | + $cls = static::getOMClass(false); |
|
272 | + // populate the object(s) |
|
273 | + while ($row = $dataFetcher->fetch()) { |
|
274 | + $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
275 | + if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
276 | + // We no longer rehydrate the object, since this can cause data loss. |
|
277 | + // See http://www.propelorm.org/ticket/509 |
|
278 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
279 | + $results[] = $obj; |
|
280 | + } else { |
|
281 | + /** @var Channel $obj */ |
|
282 | + $obj = new $cls(); |
|
283 | + $obj->hydrate($row); |
|
284 | + $results[] = $obj; |
|
285 | + ChannelTableMap::addInstanceToPool($obj, $key); |
|
286 | + } // if key exists |
|
287 | + } |
|
288 | + |
|
289 | + return $results; |
|
290 | + } |
|
291 | + /** |
|
292 | + * Add all the columns needed to create a new object. |
|
293 | + * |
|
294 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
295 | + * XML schema will not be added to the select list and only loaded |
|
296 | + * on demand. |
|
297 | + * |
|
298 | + * @param Criteria $criteria object containing the columns to add. |
|
299 | + * @param string $alias optional table alias |
|
300 | + * @throws PropelException Any exceptions caught during processing will be |
|
301 | + * rethrown wrapped into a PropelException. |
|
302 | + */ |
|
303 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
304 | + { |
|
305 | + if (null === $alias) { |
|
306 | + $criteria->addSelectColumn(ChannelTableMap::COL_ID); |
|
307 | + $criteria->addSelectColumn(ChannelTableMap::COL_INSTANCE_NAME); |
|
308 | + $criteria->addSelectColumn(ChannelTableMap::COL_NAME); |
|
309 | + } else { |
|
310 | + $criteria->addSelectColumn($alias . '.id'); |
|
311 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
312 | + $criteria->addSelectColumn($alias . '.name'); |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Returns the TableMap related to this object. |
|
318 | + * This method is not needed for general use but a specific application could have a need. |
|
319 | + * @return TableMap |
|
320 | + * @throws PropelException Any exceptions caught during processing will be |
|
321 | + * rethrown wrapped into a PropelException. |
|
322 | + */ |
|
323 | + public static function getTableMap() |
|
324 | + { |
|
325 | + return Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME)->getTable(ChannelTableMap::TABLE_NAME); |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Add a TableMap instance to the database for this tableMap class. |
|
330 | + */ |
|
331 | + public static function buildTableMap() |
|
332 | + { |
|
333 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME); |
|
334 | + if (!$dbMap->hasTable(ChannelTableMap::TABLE_NAME)) { |
|
335 | + $dbMap->addTableObject(new ChannelTableMap()); |
|
336 | + } |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * Performs a DELETE on the database, given a Channel or Criteria object OR a primary key value. |
|
341 | + * |
|
342 | + * @param mixed $values Criteria or Channel object or primary key or array of primary keys |
|
343 | + * which is used to create the DELETE statement |
|
344 | + * @param ConnectionInterface $con the connection to use |
|
345 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
346 | + * if supported by native driver or if emulated using Propel. |
|
347 | + * @throws PropelException Any exceptions caught during processing will be |
|
348 | + * rethrown wrapped into a PropelException. |
|
349 | + */ |
|
350 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
351 | + { |
|
352 | + if (null === $con) { |
|
353 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
354 | + } |
|
355 | + |
|
356 | + if ($values instanceof Criteria) { |
|
357 | + // rename for clarity |
|
358 | + $criteria = $values; |
|
359 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\Channel) { // it's a model object |
|
360 | + // create criteria based on pk values |
|
361 | + $criteria = $values->buildPkeyCriteria(); |
|
362 | + } else { // it's a primary key, or an array of pks |
|
363 | + $criteria = new Criteria(ChannelTableMap::DATABASE_NAME); |
|
364 | + $criteria->add(ChannelTableMap::COL_ID, (array) $values, Criteria::IN); |
|
365 | + } |
|
366 | + |
|
367 | + $query = ChannelQuery::create()->mergeWith($criteria); |
|
368 | + |
|
369 | + if ($values instanceof Criteria) { |
|
370 | + ChannelTableMap::clearInstancePool(); |
|
371 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
372 | + foreach ((array) $values as $singleval) { |
|
373 | + ChannelTableMap::removeInstanceFromPool($singleval); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + return $query->delete($con); |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Deletes all rows from the channel table. |
|
382 | + * |
|
383 | + * @param ConnectionInterface $con the connection to use |
|
384 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
385 | + */ |
|
386 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
387 | + { |
|
388 | + return ChannelQuery::create()->doDeleteAll($con); |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Performs an INSERT on the database, given a Channel or Criteria object. |
|
393 | + * |
|
394 | + * @param mixed $criteria Criteria or Channel object containing data that is used to create the INSERT statement. |
|
395 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
396 | + * @return mixed The new primary key. |
|
397 | + * @throws PropelException Any exceptions caught during processing will be |
|
398 | + * rethrown wrapped into a PropelException. |
|
399 | + */ |
|
400 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
401 | + { |
|
402 | + if (null === $con) { |
|
403 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
404 | + } |
|
405 | + |
|
406 | + if ($criteria instanceof Criteria) { |
|
407 | + $criteria = clone $criteria; // rename for clarity |
|
408 | + } else { |
|
409 | + $criteria = $criteria->buildCriteria(); // build Criteria from Channel object |
|
410 | + } |
|
411 | + |
|
412 | + if ($criteria->containsKey(ChannelTableMap::COL_ID) && $criteria->keyContainsValue(ChannelTableMap::COL_ID) ) { |
|
413 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ChannelTableMap::COL_ID.')'); |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + // Set the correct dbName |
|
418 | + $query = ChannelQuery::create()->mergeWith($criteria); |
|
419 | + |
|
420 | + // use transaction because $criteria could contain info |
|
421 | + // for more than one table (I guess, conceivably) |
|
422 | + return $con->transaction(function () use ($con, $query) { |
|
423 | + return $query->doInsert($con); |
|
424 | + }); |
|
425 | + } |
|
426 | 426 | |
427 | 427 | } // ChannelTableMap |
428 | 428 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * first dimension keys are the type constants |
98 | 98 | * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
99 | 99 | */ |
100 | - protected static $fieldNames = array ( |
|
101 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | - self::TYPE_COLNAME => array(ChannelTableMap::COL_ID, ChannelTableMap::COL_INSTANCE_NAME, ChannelTableMap::COL_NAME, ), |
|
104 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
100 | + protected static $fieldNames = array( |
|
101 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name',), |
|
102 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'name',), |
|
103 | + self::TYPE_COLNAME => array(ChannelTableMap::COL_ID, ChannelTableMap::COL_INSTANCE_NAME, ChannelTableMap::COL_NAME,), |
|
104 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'name',), |
|
105 | + self::TYPE_NUM => array(0, 1, 2,) |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | /** |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | * first dimension keys are the type constants |
112 | 112 | * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
113 | 113 | */ |
114 | - protected static $fieldKeys = array ( |
|
115 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | - self::TYPE_COLNAME => array(ChannelTableMap::COL_ID => 0, ChannelTableMap::COL_INSTANCE_NAME => 1, ChannelTableMap::COL_NAME => 2, ), |
|
118 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
114 | + protected static $fieldKeys = array( |
|
115 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2,), |
|
116 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2,), |
|
117 | + self::TYPE_COLNAME => array(ChannelTableMap::COL_ID => 0, ChannelTableMap::COL_INSTANCE_NAME => 1, ChannelTableMap::COL_NAME => 2,), |
|
118 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2,), |
|
119 | + self::TYPE_NUM => array(0, 1, 2,) |
|
120 | 120 | ); |
121 | 121 | |
122 | 122 | /** |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function buildRelations() |
148 | 148 | { |
149 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
149 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array( |
|
150 | 150 | 0 => |
151 | - array ( |
|
151 | + array( |
|
152 | 152 | 0 => ':instance_name', |
153 | 153 | 1 => ':name', |
154 | 154 | ), |
155 | 155 | ), null, null, null, false); |
156 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
156 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array( |
|
157 | 157 | 0 => |
158 | - array ( |
|
158 | + array( |
|
159 | 159 | 0 => ':channel_id', |
160 | 160 | 1 => ':id', |
161 | 161 | ), |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | $criteria = $criteria->buildCriteria(); // build Criteria from Channel object |
410 | 410 | } |
411 | 411 | |
412 | - if ($criteria->containsKey(ChannelTableMap::COL_ID) && $criteria->keyContainsValue(ChannelTableMap::COL_ID) ) { |
|
413 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ChannelTableMap::COL_ID.')'); |
|
412 | + if ($criteria->containsKey(ChannelTableMap::COL_ID) && $criteria->keyContainsValue(ChannelTableMap::COL_ID)) { |
|
413 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ChannelTableMap::COL_ID . ')'); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | // use transaction because $criteria could contain info |
421 | 421 | // for more than one table (I guess, conceivably) |
422 | - return $con->transaction(function () use ($con, $query) { |
|
422 | + return $con->transaction(function() use ($con, $query) { |
|
423 | 423 | return $query->doInsert($con); |
424 | 424 | }); |
425 | 425 | } |
@@ -28,425 +28,425 @@ |
||
28 | 28 | */ |
29 | 29 | class ConnectionTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ConnectionTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'connection'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Connection'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Connection'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 6; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 6; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'connection.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'connection.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the user_id field |
|
86 | - */ |
|
87 | - const COL_USER_ID = 'connection.user_id'; |
|
88 | - |
|
89 | - /** |
|
90 | - * the column name for the peer field |
|
91 | - */ |
|
92 | - const COL_PEER = 'connection.peer'; |
|
93 | - |
|
94 | - /** |
|
95 | - * the column name for the started field |
|
96 | - */ |
|
97 | - const COL_STARTED = 'connection.started'; |
|
98 | - |
|
99 | - /** |
|
100 | - * the column name for the type field |
|
101 | - */ |
|
102 | - const COL_TYPE = 'connection.type'; |
|
103 | - |
|
104 | - /** |
|
105 | - * The default string format for model objects of the related table |
|
106 | - */ |
|
107 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
108 | - |
|
109 | - /** |
|
110 | - * holds an array of fieldnames |
|
111 | - * |
|
112 | - * first dimension keys are the type constants |
|
113 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
114 | - */ |
|
115 | - protected static $fieldNames = array ( |
|
116 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'Peer', 'Started', 'Type', ), |
|
117 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'peer', 'started', 'type', ), |
|
118 | - self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID, ConnectionTableMap::COL_INSTANCE_NAME, ConnectionTableMap::COL_USER_ID, ConnectionTableMap::COL_PEER, ConnectionTableMap::COL_STARTED, ConnectionTableMap::COL_TYPE, ), |
|
119 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'peer', 'started', 'type', ), |
|
120 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
121 | - ); |
|
122 | - |
|
123 | - /** |
|
124 | - * holds an array of keys for quick access to the fieldnames array |
|
125 | - * |
|
126 | - * first dimension keys are the type constants |
|
127 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
128 | - */ |
|
129 | - protected static $fieldKeys = array ( |
|
130 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'Peer' => 3, 'Started' => 4, 'Type' => 5, ), |
|
131 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
132 | - self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID => 0, ConnectionTableMap::COL_INSTANCE_NAME => 1, ConnectionTableMap::COL_USER_ID => 2, ConnectionTableMap::COL_PEER => 3, ConnectionTableMap::COL_STARTED => 4, ConnectionTableMap::COL_TYPE => 5, ), |
|
133 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
134 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
135 | - ); |
|
136 | - |
|
137 | - /** |
|
138 | - * Initialize the table attributes and columns |
|
139 | - * Relations are not initialized by this method since they are lazy loaded |
|
140 | - * |
|
141 | - * @return void |
|
142 | - * @throws PropelException |
|
143 | - */ |
|
144 | - public function initialize() |
|
145 | - { |
|
146 | - // attributes |
|
147 | - $this->setName('connection'); |
|
148 | - $this->setPhpName('Connection'); |
|
149 | - $this->setIdentifierQuoting(false); |
|
150 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\Connection'); |
|
151 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
152 | - $this->setUseIdGenerator(true); |
|
153 | - // columns |
|
154 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
155 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
156 | - $this->addForeignKey('user_id', 'UserId', 'INTEGER', 'user', 'id', false, null, null); |
|
157 | - $this->addColumn('peer', 'Peer', 'VARCHAR', true, 255, null); |
|
158 | - $this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
|
159 | - $this->addColumn('type', 'Type', 'VARCHAR', true, 255, null); |
|
160 | - } // initialize() |
|
161 | - |
|
162 | - /** |
|
163 | - * Build the RelationMap objects for this table relationships |
|
164 | - */ |
|
165 | - public function buildRelations() |
|
166 | - { |
|
167 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ConnectionTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'connection'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Connection'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Connection'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 6; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 6; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'connection.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'connection.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the user_id field |
|
86 | + */ |
|
87 | + const COL_USER_ID = 'connection.user_id'; |
|
88 | + |
|
89 | + /** |
|
90 | + * the column name for the peer field |
|
91 | + */ |
|
92 | + const COL_PEER = 'connection.peer'; |
|
93 | + |
|
94 | + /** |
|
95 | + * the column name for the started field |
|
96 | + */ |
|
97 | + const COL_STARTED = 'connection.started'; |
|
98 | + |
|
99 | + /** |
|
100 | + * the column name for the type field |
|
101 | + */ |
|
102 | + const COL_TYPE = 'connection.type'; |
|
103 | + |
|
104 | + /** |
|
105 | + * The default string format for model objects of the related table |
|
106 | + */ |
|
107 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
108 | + |
|
109 | + /** |
|
110 | + * holds an array of fieldnames |
|
111 | + * |
|
112 | + * first dimension keys are the type constants |
|
113 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
114 | + */ |
|
115 | + protected static $fieldNames = array ( |
|
116 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'Peer', 'Started', 'Type', ), |
|
117 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'peer', 'started', 'type', ), |
|
118 | + self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID, ConnectionTableMap::COL_INSTANCE_NAME, ConnectionTableMap::COL_USER_ID, ConnectionTableMap::COL_PEER, ConnectionTableMap::COL_STARTED, ConnectionTableMap::COL_TYPE, ), |
|
119 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'peer', 'started', 'type', ), |
|
120 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
121 | + ); |
|
122 | + |
|
123 | + /** |
|
124 | + * holds an array of keys for quick access to the fieldnames array |
|
125 | + * |
|
126 | + * first dimension keys are the type constants |
|
127 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
128 | + */ |
|
129 | + protected static $fieldKeys = array ( |
|
130 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'Peer' => 3, 'Started' => 4, 'Type' => 5, ), |
|
131 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
132 | + self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID => 0, ConnectionTableMap::COL_INSTANCE_NAME => 1, ConnectionTableMap::COL_USER_ID => 2, ConnectionTableMap::COL_PEER => 3, ConnectionTableMap::COL_STARTED => 4, ConnectionTableMap::COL_TYPE => 5, ), |
|
133 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
134 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
135 | + ); |
|
136 | + |
|
137 | + /** |
|
138 | + * Initialize the table attributes and columns |
|
139 | + * Relations are not initialized by this method since they are lazy loaded |
|
140 | + * |
|
141 | + * @return void |
|
142 | + * @throws PropelException |
|
143 | + */ |
|
144 | + public function initialize() |
|
145 | + { |
|
146 | + // attributes |
|
147 | + $this->setName('connection'); |
|
148 | + $this->setPhpName('Connection'); |
|
149 | + $this->setIdentifierQuoting(false); |
|
150 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\Connection'); |
|
151 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
152 | + $this->setUseIdGenerator(true); |
|
153 | + // columns |
|
154 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
155 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
156 | + $this->addForeignKey('user_id', 'UserId', 'INTEGER', 'user', 'id', false, null, null); |
|
157 | + $this->addColumn('peer', 'Peer', 'VARCHAR', true, 255, null); |
|
158 | + $this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
|
159 | + $this->addColumn('type', 'Type', 'VARCHAR', true, 255, null); |
|
160 | + } // initialize() |
|
161 | + |
|
162 | + /** |
|
163 | + * Build the RelationMap objects for this table relationships |
|
164 | + */ |
|
165 | + public function buildRelations() |
|
166 | + { |
|
167 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
168 | 168 | 0 => |
169 | 169 | array ( |
170 | - 0 => ':instance_name', |
|
171 | - 1 => ':name', |
|
170 | + 0 => ':instance_name', |
|
171 | + 1 => ':name', |
|
172 | 172 | ), |
173 | 173 | ), null, null, null, false); |
174 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
174 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
175 | 175 | 0 => |
176 | 176 | array ( |
177 | - 0 => ':user_id', |
|
178 | - 1 => ':id', |
|
177 | + 0 => ':user_id', |
|
178 | + 1 => ':id', |
|
179 | 179 | ), |
180 | 180 | ), null, null, null, false); |
181 | - } // buildRelations() |
|
182 | - |
|
183 | - /** |
|
184 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
185 | - * |
|
186 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
187 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
188 | - * |
|
189 | - * @param array $row resultset row. |
|
190 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
191 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
192 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
193 | - * |
|
194 | - * @return string The primary key hash of the row |
|
195 | - */ |
|
196 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
197 | - { |
|
198 | - // If the PK cannot be derived from the row, return NULL. |
|
199 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
200 | - return null; |
|
201 | - } |
|
202 | - |
|
203 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Retrieves the primary key from the DB resultset row |
|
208 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
209 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
210 | - * |
|
211 | - * @param array $row resultset row. |
|
212 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
213 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
214 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
215 | - * |
|
216 | - * @return mixed The primary key of the row |
|
217 | - */ |
|
218 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
219 | - { |
|
220 | - return (int) $row[ |
|
221 | - $indexType == TableMap::TYPE_NUM |
|
222 | - ? 0 + $offset |
|
223 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
224 | - ]; |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * The class that the tableMap will make instances of. |
|
229 | - * |
|
230 | - * If $withPrefix is true, the returned path |
|
231 | - * uses a dot-path notation which is translated into a path |
|
232 | - * relative to a location on the PHP include_path. |
|
233 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
234 | - * |
|
235 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
236 | - * @return string path.to.ClassName |
|
237 | - */ |
|
238 | - public static function getOMClass($withPrefix = true) |
|
239 | - { |
|
240 | - return $withPrefix ? ConnectionTableMap::CLASS_DEFAULT : ConnectionTableMap::OM_CLASS; |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Populates an object of the default type or an object that inherit from the default. |
|
245 | - * |
|
246 | - * @param array $row row returned by DataFetcher->fetch(). |
|
247 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
248 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
181 | + } // buildRelations() |
|
182 | + |
|
183 | + /** |
|
184 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
185 | + * |
|
186 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
187 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
188 | + * |
|
189 | + * @param array $row resultset row. |
|
190 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
191 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
192 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
193 | + * |
|
194 | + * @return string The primary key hash of the row |
|
195 | + */ |
|
196 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
197 | + { |
|
198 | + // If the PK cannot be derived from the row, return NULL. |
|
199 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
200 | + return null; |
|
201 | + } |
|
202 | + |
|
203 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Retrieves the primary key from the DB resultset row |
|
208 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
209 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
210 | + * |
|
211 | + * @param array $row resultset row. |
|
212 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
213 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
214 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
215 | + * |
|
216 | + * @return mixed The primary key of the row |
|
217 | + */ |
|
218 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
219 | + { |
|
220 | + return (int) $row[ |
|
221 | + $indexType == TableMap::TYPE_NUM |
|
222 | + ? 0 + $offset |
|
223 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
224 | + ]; |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * The class that the tableMap will make instances of. |
|
229 | + * |
|
230 | + * If $withPrefix is true, the returned path |
|
231 | + * uses a dot-path notation which is translated into a path |
|
232 | + * relative to a location on the PHP include_path. |
|
233 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
234 | + * |
|
235 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
236 | + * @return string path.to.ClassName |
|
237 | + */ |
|
238 | + public static function getOMClass($withPrefix = true) |
|
239 | + { |
|
240 | + return $withPrefix ? ConnectionTableMap::CLASS_DEFAULT : ConnectionTableMap::OM_CLASS; |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Populates an object of the default type or an object that inherit from the default. |
|
245 | + * |
|
246 | + * @param array $row row returned by DataFetcher->fetch(). |
|
247 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
248 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
249 | 249 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
250 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
251 | - * |
|
252 | - * @throws PropelException Any exceptions caught during processing will be |
|
253 | - * rethrown wrapped into a PropelException. |
|
254 | - * @return array (Connection object, last column rank) |
|
255 | - */ |
|
256 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
257 | - { |
|
258 | - $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
259 | - if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
260 | - // We no longer rehydrate the object, since this can cause data loss. |
|
261 | - // See http://www.propelorm.org/ticket/509 |
|
262 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
263 | - $col = $offset + ConnectionTableMap::NUM_HYDRATE_COLUMNS; |
|
264 | - } else { |
|
265 | - $cls = ConnectionTableMap::OM_CLASS; |
|
266 | - /** @var Connection $obj */ |
|
267 | - $obj = new $cls(); |
|
268 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
269 | - ConnectionTableMap::addInstanceToPool($obj, $key); |
|
270 | - } |
|
271 | - |
|
272 | - return array($obj, $col); |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * The returned array will contain objects of the default type or |
|
277 | - * objects that inherit from the default. |
|
278 | - * |
|
279 | - * @param DataFetcherInterface $dataFetcher |
|
280 | - * @return array |
|
281 | - * @throws PropelException Any exceptions caught during processing will be |
|
282 | - * rethrown wrapped into a PropelException. |
|
283 | - */ |
|
284 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
285 | - { |
|
286 | - $results = array(); |
|
287 | - |
|
288 | - // set the class once to avoid overhead in the loop |
|
289 | - $cls = static::getOMClass(false); |
|
290 | - // populate the object(s) |
|
291 | - while ($row = $dataFetcher->fetch()) { |
|
292 | - $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
293 | - if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
294 | - // We no longer rehydrate the object, since this can cause data loss. |
|
295 | - // See http://www.propelorm.org/ticket/509 |
|
296 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
297 | - $results[] = $obj; |
|
298 | - } else { |
|
299 | - /** @var Connection $obj */ |
|
300 | - $obj = new $cls(); |
|
301 | - $obj->hydrate($row); |
|
302 | - $results[] = $obj; |
|
303 | - ConnectionTableMap::addInstanceToPool($obj, $key); |
|
304 | - } // if key exists |
|
305 | - } |
|
306 | - |
|
307 | - return $results; |
|
308 | - } |
|
309 | - /** |
|
310 | - * Add all the columns needed to create a new object. |
|
311 | - * |
|
312 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
313 | - * XML schema will not be added to the select list and only loaded |
|
314 | - * on demand. |
|
315 | - * |
|
316 | - * @param Criteria $criteria object containing the columns to add. |
|
317 | - * @param string $alias optional table alias |
|
318 | - * @throws PropelException Any exceptions caught during processing will be |
|
319 | - * rethrown wrapped into a PropelException. |
|
320 | - */ |
|
321 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
322 | - { |
|
323 | - if (null === $alias) { |
|
324 | - $criteria->addSelectColumn(ConnectionTableMap::COL_ID); |
|
325 | - $criteria->addSelectColumn(ConnectionTableMap::COL_INSTANCE_NAME); |
|
326 | - $criteria->addSelectColumn(ConnectionTableMap::COL_USER_ID); |
|
327 | - $criteria->addSelectColumn(ConnectionTableMap::COL_PEER); |
|
328 | - $criteria->addSelectColumn(ConnectionTableMap::COL_STARTED); |
|
329 | - $criteria->addSelectColumn(ConnectionTableMap::COL_TYPE); |
|
330 | - } else { |
|
331 | - $criteria->addSelectColumn($alias . '.id'); |
|
332 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
333 | - $criteria->addSelectColumn($alias . '.user_id'); |
|
334 | - $criteria->addSelectColumn($alias . '.peer'); |
|
335 | - $criteria->addSelectColumn($alias . '.started'); |
|
336 | - $criteria->addSelectColumn($alias . '.type'); |
|
337 | - } |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Returns the TableMap related to this object. |
|
342 | - * This method is not needed for general use but a specific application could have a need. |
|
343 | - * @return TableMap |
|
344 | - * @throws PropelException Any exceptions caught during processing will be |
|
345 | - * rethrown wrapped into a PropelException. |
|
346 | - */ |
|
347 | - public static function getTableMap() |
|
348 | - { |
|
349 | - return Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME)->getTable(ConnectionTableMap::TABLE_NAME); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Add a TableMap instance to the database for this tableMap class. |
|
354 | - */ |
|
355 | - public static function buildTableMap() |
|
356 | - { |
|
357 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME); |
|
358 | - if (!$dbMap->hasTable(ConnectionTableMap::TABLE_NAME)) { |
|
359 | - $dbMap->addTableObject(new ConnectionTableMap()); |
|
360 | - } |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Performs a DELETE on the database, given a Connection or Criteria object OR a primary key value. |
|
365 | - * |
|
366 | - * @param mixed $values Criteria or Connection object or primary key or array of primary keys |
|
367 | - * which is used to create the DELETE statement |
|
368 | - * @param ConnectionInterface $con the connection to use |
|
369 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
370 | - * if supported by native driver or if emulated using Propel. |
|
371 | - * @throws PropelException Any exceptions caught during processing will be |
|
372 | - * rethrown wrapped into a PropelException. |
|
373 | - */ |
|
374 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
375 | - { |
|
376 | - if (null === $con) { |
|
377 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
378 | - } |
|
379 | - |
|
380 | - if ($values instanceof Criteria) { |
|
381 | - // rename for clarity |
|
382 | - $criteria = $values; |
|
383 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\Connection) { // it's a model object |
|
384 | - // create criteria based on pk values |
|
385 | - $criteria = $values->buildPkeyCriteria(); |
|
386 | - } else { // it's a primary key, or an array of pks |
|
387 | - $criteria = new Criteria(ConnectionTableMap::DATABASE_NAME); |
|
388 | - $criteria->add(ConnectionTableMap::COL_ID, (array) $values, Criteria::IN); |
|
389 | - } |
|
390 | - |
|
391 | - $query = ConnectionQuery::create()->mergeWith($criteria); |
|
392 | - |
|
393 | - if ($values instanceof Criteria) { |
|
394 | - ConnectionTableMap::clearInstancePool(); |
|
395 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
396 | - foreach ((array) $values as $singleval) { |
|
397 | - ConnectionTableMap::removeInstanceFromPool($singleval); |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - return $query->delete($con); |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * Deletes all rows from the connection table. |
|
406 | - * |
|
407 | - * @param ConnectionInterface $con the connection to use |
|
408 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
409 | - */ |
|
410 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
411 | - { |
|
412 | - return ConnectionQuery::create()->doDeleteAll($con); |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * Performs an INSERT on the database, given a Connection or Criteria object. |
|
417 | - * |
|
418 | - * @param mixed $criteria Criteria or Connection object containing data that is used to create the INSERT statement. |
|
419 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
420 | - * @return mixed The new primary key. |
|
421 | - * @throws PropelException Any exceptions caught during processing will be |
|
422 | - * rethrown wrapped into a PropelException. |
|
423 | - */ |
|
424 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
425 | - { |
|
426 | - if (null === $con) { |
|
427 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
428 | - } |
|
429 | - |
|
430 | - if ($criteria instanceof Criteria) { |
|
431 | - $criteria = clone $criteria; // rename for clarity |
|
432 | - } else { |
|
433 | - $criteria = $criteria->buildCriteria(); // build Criteria from Connection object |
|
434 | - } |
|
435 | - |
|
436 | - if ($criteria->containsKey(ConnectionTableMap::COL_ID) && $criteria->keyContainsValue(ConnectionTableMap::COL_ID) ) { |
|
437 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConnectionTableMap::COL_ID.')'); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - // Set the correct dbName |
|
442 | - $query = ConnectionQuery::create()->mergeWith($criteria); |
|
443 | - |
|
444 | - // use transaction because $criteria could contain info |
|
445 | - // for more than one table (I guess, conceivably) |
|
446 | - return $con->transaction(function () use ($con, $query) { |
|
447 | - return $query->doInsert($con); |
|
448 | - }); |
|
449 | - } |
|
250 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
251 | + * |
|
252 | + * @throws PropelException Any exceptions caught during processing will be |
|
253 | + * rethrown wrapped into a PropelException. |
|
254 | + * @return array (Connection object, last column rank) |
|
255 | + */ |
|
256 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
257 | + { |
|
258 | + $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
259 | + if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
260 | + // We no longer rehydrate the object, since this can cause data loss. |
|
261 | + // See http://www.propelorm.org/ticket/509 |
|
262 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
263 | + $col = $offset + ConnectionTableMap::NUM_HYDRATE_COLUMNS; |
|
264 | + } else { |
|
265 | + $cls = ConnectionTableMap::OM_CLASS; |
|
266 | + /** @var Connection $obj */ |
|
267 | + $obj = new $cls(); |
|
268 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
269 | + ConnectionTableMap::addInstanceToPool($obj, $key); |
|
270 | + } |
|
271 | + |
|
272 | + return array($obj, $col); |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * The returned array will contain objects of the default type or |
|
277 | + * objects that inherit from the default. |
|
278 | + * |
|
279 | + * @param DataFetcherInterface $dataFetcher |
|
280 | + * @return array |
|
281 | + * @throws PropelException Any exceptions caught during processing will be |
|
282 | + * rethrown wrapped into a PropelException. |
|
283 | + */ |
|
284 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
285 | + { |
|
286 | + $results = array(); |
|
287 | + |
|
288 | + // set the class once to avoid overhead in the loop |
|
289 | + $cls = static::getOMClass(false); |
|
290 | + // populate the object(s) |
|
291 | + while ($row = $dataFetcher->fetch()) { |
|
292 | + $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
293 | + if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
294 | + // We no longer rehydrate the object, since this can cause data loss. |
|
295 | + // See http://www.propelorm.org/ticket/509 |
|
296 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
297 | + $results[] = $obj; |
|
298 | + } else { |
|
299 | + /** @var Connection $obj */ |
|
300 | + $obj = new $cls(); |
|
301 | + $obj->hydrate($row); |
|
302 | + $results[] = $obj; |
|
303 | + ConnectionTableMap::addInstanceToPool($obj, $key); |
|
304 | + } // if key exists |
|
305 | + } |
|
306 | + |
|
307 | + return $results; |
|
308 | + } |
|
309 | + /** |
|
310 | + * Add all the columns needed to create a new object. |
|
311 | + * |
|
312 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
313 | + * XML schema will not be added to the select list and only loaded |
|
314 | + * on demand. |
|
315 | + * |
|
316 | + * @param Criteria $criteria object containing the columns to add. |
|
317 | + * @param string $alias optional table alias |
|
318 | + * @throws PropelException Any exceptions caught during processing will be |
|
319 | + * rethrown wrapped into a PropelException. |
|
320 | + */ |
|
321 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
322 | + { |
|
323 | + if (null === $alias) { |
|
324 | + $criteria->addSelectColumn(ConnectionTableMap::COL_ID); |
|
325 | + $criteria->addSelectColumn(ConnectionTableMap::COL_INSTANCE_NAME); |
|
326 | + $criteria->addSelectColumn(ConnectionTableMap::COL_USER_ID); |
|
327 | + $criteria->addSelectColumn(ConnectionTableMap::COL_PEER); |
|
328 | + $criteria->addSelectColumn(ConnectionTableMap::COL_STARTED); |
|
329 | + $criteria->addSelectColumn(ConnectionTableMap::COL_TYPE); |
|
330 | + } else { |
|
331 | + $criteria->addSelectColumn($alias . '.id'); |
|
332 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
333 | + $criteria->addSelectColumn($alias . '.user_id'); |
|
334 | + $criteria->addSelectColumn($alias . '.peer'); |
|
335 | + $criteria->addSelectColumn($alias . '.started'); |
|
336 | + $criteria->addSelectColumn($alias . '.type'); |
|
337 | + } |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Returns the TableMap related to this object. |
|
342 | + * This method is not needed for general use but a specific application could have a need. |
|
343 | + * @return TableMap |
|
344 | + * @throws PropelException Any exceptions caught during processing will be |
|
345 | + * rethrown wrapped into a PropelException. |
|
346 | + */ |
|
347 | + public static function getTableMap() |
|
348 | + { |
|
349 | + return Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME)->getTable(ConnectionTableMap::TABLE_NAME); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Add a TableMap instance to the database for this tableMap class. |
|
354 | + */ |
|
355 | + public static function buildTableMap() |
|
356 | + { |
|
357 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME); |
|
358 | + if (!$dbMap->hasTable(ConnectionTableMap::TABLE_NAME)) { |
|
359 | + $dbMap->addTableObject(new ConnectionTableMap()); |
|
360 | + } |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Performs a DELETE on the database, given a Connection or Criteria object OR a primary key value. |
|
365 | + * |
|
366 | + * @param mixed $values Criteria or Connection object or primary key or array of primary keys |
|
367 | + * which is used to create the DELETE statement |
|
368 | + * @param ConnectionInterface $con the connection to use |
|
369 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
370 | + * if supported by native driver or if emulated using Propel. |
|
371 | + * @throws PropelException Any exceptions caught during processing will be |
|
372 | + * rethrown wrapped into a PropelException. |
|
373 | + */ |
|
374 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
375 | + { |
|
376 | + if (null === $con) { |
|
377 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
378 | + } |
|
379 | + |
|
380 | + if ($values instanceof Criteria) { |
|
381 | + // rename for clarity |
|
382 | + $criteria = $values; |
|
383 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\Connection) { // it's a model object |
|
384 | + // create criteria based on pk values |
|
385 | + $criteria = $values->buildPkeyCriteria(); |
|
386 | + } else { // it's a primary key, or an array of pks |
|
387 | + $criteria = new Criteria(ConnectionTableMap::DATABASE_NAME); |
|
388 | + $criteria->add(ConnectionTableMap::COL_ID, (array) $values, Criteria::IN); |
|
389 | + } |
|
390 | + |
|
391 | + $query = ConnectionQuery::create()->mergeWith($criteria); |
|
392 | + |
|
393 | + if ($values instanceof Criteria) { |
|
394 | + ConnectionTableMap::clearInstancePool(); |
|
395 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
396 | + foreach ((array) $values as $singleval) { |
|
397 | + ConnectionTableMap::removeInstanceFromPool($singleval); |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + return $query->delete($con); |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * Deletes all rows from the connection table. |
|
406 | + * |
|
407 | + * @param ConnectionInterface $con the connection to use |
|
408 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
409 | + */ |
|
410 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
411 | + { |
|
412 | + return ConnectionQuery::create()->doDeleteAll($con); |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * Performs an INSERT on the database, given a Connection or Criteria object. |
|
417 | + * |
|
418 | + * @param mixed $criteria Criteria or Connection object containing data that is used to create the INSERT statement. |
|
419 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
420 | + * @return mixed The new primary key. |
|
421 | + * @throws PropelException Any exceptions caught during processing will be |
|
422 | + * rethrown wrapped into a PropelException. |
|
423 | + */ |
|
424 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
425 | + { |
|
426 | + if (null === $con) { |
|
427 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
428 | + } |
|
429 | + |
|
430 | + if ($criteria instanceof Criteria) { |
|
431 | + $criteria = clone $criteria; // rename for clarity |
|
432 | + } else { |
|
433 | + $criteria = $criteria->buildCriteria(); // build Criteria from Connection object |
|
434 | + } |
|
435 | + |
|
436 | + if ($criteria->containsKey(ConnectionTableMap::COL_ID) && $criteria->keyContainsValue(ConnectionTableMap::COL_ID) ) { |
|
437 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConnectionTableMap::COL_ID.')'); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + // Set the correct dbName |
|
442 | + $query = ConnectionQuery::create()->mergeWith($criteria); |
|
443 | + |
|
444 | + // use transaction because $criteria could contain info |
|
445 | + // for more than one table (I guess, conceivably) |
|
446 | + return $con->transaction(function () use ($con, $query) { |
|
447 | + return $query->doInsert($con); |
|
448 | + }); |
|
449 | + } |
|
450 | 450 | |
451 | 451 | } // ConnectionTableMap |
452 | 452 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * first dimension keys are the type constants |
113 | 113 | * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
114 | 114 | */ |
115 | - protected static $fieldNames = array ( |
|
116 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'Peer', 'Started', 'Type', ), |
|
117 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'peer', 'started', 'type', ), |
|
118 | - self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID, ConnectionTableMap::COL_INSTANCE_NAME, ConnectionTableMap::COL_USER_ID, ConnectionTableMap::COL_PEER, ConnectionTableMap::COL_STARTED, ConnectionTableMap::COL_TYPE, ), |
|
119 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'peer', 'started', 'type', ), |
|
120 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
115 | + protected static $fieldNames = array( |
|
116 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'Peer', 'Started', 'Type',), |
|
117 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'peer', 'started', 'type',), |
|
118 | + self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID, ConnectionTableMap::COL_INSTANCE_NAME, ConnectionTableMap::COL_USER_ID, ConnectionTableMap::COL_PEER, ConnectionTableMap::COL_STARTED, ConnectionTableMap::COL_TYPE,), |
|
119 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'peer', 'started', 'type',), |
|
120 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5,) |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | /** |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | * first dimension keys are the type constants |
127 | 127 | * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
128 | 128 | */ |
129 | - protected static $fieldKeys = array ( |
|
130 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'Peer' => 3, 'Started' => 4, 'Type' => 5, ), |
|
131 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
132 | - self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID => 0, ConnectionTableMap::COL_INSTANCE_NAME => 1, ConnectionTableMap::COL_USER_ID => 2, ConnectionTableMap::COL_PEER => 3, ConnectionTableMap::COL_STARTED => 4, ConnectionTableMap::COL_TYPE => 5, ), |
|
133 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
134 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
129 | + protected static $fieldKeys = array( |
|
130 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'Peer' => 3, 'Started' => 4, 'Type' => 5,), |
|
131 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'peer' => 3, 'started' => 4, 'type' => 5,), |
|
132 | + self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID => 0, ConnectionTableMap::COL_INSTANCE_NAME => 1, ConnectionTableMap::COL_USER_ID => 2, ConnectionTableMap::COL_PEER => 3, ConnectionTableMap::COL_STARTED => 4, ConnectionTableMap::COL_TYPE => 5,), |
|
133 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'peer' => 3, 'started' => 4, 'type' => 5,), |
|
134 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5,) |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | /** |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function buildRelations() |
166 | 166 | { |
167 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
167 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array( |
|
168 | 168 | 0 => |
169 | - array ( |
|
169 | + array( |
|
170 | 170 | 0 => ':instance_name', |
171 | 171 | 1 => ':name', |
172 | 172 | ), |
173 | 173 | ), null, null, null, false); |
174 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
174 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array( |
|
175 | 175 | 0 => |
176 | - array ( |
|
176 | + array( |
|
177 | 177 | 0 => ':user_id', |
178 | 178 | 1 => ':id', |
179 | 179 | ), |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | $criteria = $criteria->buildCriteria(); // build Criteria from Connection object |
434 | 434 | } |
435 | 435 | |
436 | - if ($criteria->containsKey(ConnectionTableMap::COL_ID) && $criteria->keyContainsValue(ConnectionTableMap::COL_ID) ) { |
|
437 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConnectionTableMap::COL_ID.')'); |
|
436 | + if ($criteria->containsKey(ConnectionTableMap::COL_ID) && $criteria->keyContainsValue(ConnectionTableMap::COL_ID)) { |
|
437 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConnectionTableMap::COL_ID . ')'); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | |
444 | 444 | // use transaction because $criteria could contain info |
445 | 445 | // for more than one table (I guess, conceivably) |
446 | - return $con->transaction(function () use ($con, $query) { |
|
446 | + return $con->transaction(function() use ($con, $query) { |
|
447 | 447 | return $query->doInsert($con); |
448 | 448 | }); |
449 | 449 | } |
@@ -28,395 +28,395 @@ |
||
28 | 28 | */ |
29 | 29 | class InstanceTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.InstanceTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'instance'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Instance'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Instance'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 1; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 1; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the name field |
|
76 | - */ |
|
77 | - const COL_NAME = 'instance.name'; |
|
78 | - |
|
79 | - /** |
|
80 | - * The default string format for model objects of the related table |
|
81 | - */ |
|
82 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
83 | - |
|
84 | - /** |
|
85 | - * holds an array of fieldnames |
|
86 | - * |
|
87 | - * first dimension keys are the type constants |
|
88 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
89 | - */ |
|
90 | - protected static $fieldNames = array ( |
|
91 | - self::TYPE_PHPNAME => array('Name', ), |
|
92 | - self::TYPE_CAMELNAME => array('name', ), |
|
93 | - self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME, ), |
|
94 | - self::TYPE_FIELDNAME => array('name', ), |
|
95 | - self::TYPE_NUM => array(0, ) |
|
96 | - ); |
|
97 | - |
|
98 | - /** |
|
99 | - * holds an array of keys for quick access to the fieldnames array |
|
100 | - * |
|
101 | - * first dimension keys are the type constants |
|
102 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
103 | - */ |
|
104 | - protected static $fieldKeys = array ( |
|
105 | - self::TYPE_PHPNAME => array('Name' => 0, ), |
|
106 | - self::TYPE_CAMELNAME => array('name' => 0, ), |
|
107 | - self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME => 0, ), |
|
108 | - self::TYPE_FIELDNAME => array('name' => 0, ), |
|
109 | - self::TYPE_NUM => array(0, ) |
|
110 | - ); |
|
111 | - |
|
112 | - /** |
|
113 | - * Initialize the table attributes and columns |
|
114 | - * Relations are not initialized by this method since they are lazy loaded |
|
115 | - * |
|
116 | - * @return void |
|
117 | - * @throws PropelException |
|
118 | - */ |
|
119 | - public function initialize() |
|
120 | - { |
|
121 | - // attributes |
|
122 | - $this->setName('instance'); |
|
123 | - $this->setPhpName('Instance'); |
|
124 | - $this->setIdentifierQuoting(false); |
|
125 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\Instance'); |
|
126 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
127 | - $this->setUseIdGenerator(false); |
|
128 | - // columns |
|
129 | - $this->addPrimaryKey('name', 'Name', 'VARCHAR', true, 255, null); |
|
130 | - } // initialize() |
|
131 | - |
|
132 | - /** |
|
133 | - * Build the RelationMap objects for this table relationships |
|
134 | - */ |
|
135 | - public function buildRelations() |
|
136 | - { |
|
137 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::ONE_TO_MANY, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.InstanceTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'instance'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Instance'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Instance'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 1; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 1; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the name field |
|
76 | + */ |
|
77 | + const COL_NAME = 'instance.name'; |
|
78 | + |
|
79 | + /** |
|
80 | + * The default string format for model objects of the related table |
|
81 | + */ |
|
82 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
83 | + |
|
84 | + /** |
|
85 | + * holds an array of fieldnames |
|
86 | + * |
|
87 | + * first dimension keys are the type constants |
|
88 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
89 | + */ |
|
90 | + protected static $fieldNames = array ( |
|
91 | + self::TYPE_PHPNAME => array('Name', ), |
|
92 | + self::TYPE_CAMELNAME => array('name', ), |
|
93 | + self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME, ), |
|
94 | + self::TYPE_FIELDNAME => array('name', ), |
|
95 | + self::TYPE_NUM => array(0, ) |
|
96 | + ); |
|
97 | + |
|
98 | + /** |
|
99 | + * holds an array of keys for quick access to the fieldnames array |
|
100 | + * |
|
101 | + * first dimension keys are the type constants |
|
102 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
103 | + */ |
|
104 | + protected static $fieldKeys = array ( |
|
105 | + self::TYPE_PHPNAME => array('Name' => 0, ), |
|
106 | + self::TYPE_CAMELNAME => array('name' => 0, ), |
|
107 | + self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME => 0, ), |
|
108 | + self::TYPE_FIELDNAME => array('name' => 0, ), |
|
109 | + self::TYPE_NUM => array(0, ) |
|
110 | + ); |
|
111 | + |
|
112 | + /** |
|
113 | + * Initialize the table attributes and columns |
|
114 | + * Relations are not initialized by this method since they are lazy loaded |
|
115 | + * |
|
116 | + * @return void |
|
117 | + * @throws PropelException |
|
118 | + */ |
|
119 | + public function initialize() |
|
120 | + { |
|
121 | + // attributes |
|
122 | + $this->setName('instance'); |
|
123 | + $this->setPhpName('Instance'); |
|
124 | + $this->setIdentifierQuoting(false); |
|
125 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\Instance'); |
|
126 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
127 | + $this->setUseIdGenerator(false); |
|
128 | + // columns |
|
129 | + $this->addPrimaryKey('name', 'Name', 'VARCHAR', true, 255, null); |
|
130 | + } // initialize() |
|
131 | + |
|
132 | + /** |
|
133 | + * Build the RelationMap objects for this table relationships |
|
134 | + */ |
|
135 | + public function buildRelations() |
|
136 | + { |
|
137 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::ONE_TO_MANY, array ( |
|
138 | 138 | 0 => |
139 | 139 | array ( |
140 | - 0 => ':instance_name', |
|
141 | - 1 => ':name', |
|
140 | + 0 => ':instance_name', |
|
141 | + 1 => ':name', |
|
142 | 142 | ), |
143 | 143 | ), null, null, 'Users', false); |
144 | - $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
144 | + $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
145 | 145 | 0 => |
146 | 146 | array ( |
147 | - 0 => ':instance_name', |
|
148 | - 1 => ':name', |
|
147 | + 0 => ':instance_name', |
|
148 | + 1 => ':name', |
|
149 | 149 | ), |
150 | 150 | ), null, null, 'Connections', false); |
151 | - $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::ONE_TO_MANY, array ( |
|
151 | + $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::ONE_TO_MANY, array ( |
|
152 | 152 | 0 => |
153 | 153 | array ( |
154 | - 0 => ':instance_name', |
|
155 | - 1 => ':name', |
|
154 | + 0 => ':instance_name', |
|
155 | + 1 => ':name', |
|
156 | 156 | ), |
157 | 157 | ), null, null, 'Channels', false); |
158 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
158 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
159 | 159 | 0 => |
160 | 160 | array ( |
161 | - 0 => ':instance_name', |
|
162 | - 1 => ':name', |
|
161 | + 0 => ':instance_name', |
|
162 | + 1 => ':name', |
|
163 | 163 | ), |
164 | 164 | ), null, null, 'Subscriptions', false); |
165 | - } // buildRelations() |
|
166 | - |
|
167 | - /** |
|
168 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
169 | - * |
|
170 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
171 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
172 | - * |
|
173 | - * @param array $row resultset row. |
|
174 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
175 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
176 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
177 | - * |
|
178 | - * @return string The primary key hash of the row |
|
179 | - */ |
|
180 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
181 | - { |
|
182 | - // If the PK cannot be derived from the row, return NULL. |
|
183 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
184 | - return null; |
|
185 | - } |
|
186 | - |
|
187 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Retrieves the primary key from the DB resultset row |
|
192 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
193 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
194 | - * |
|
195 | - * @param array $row resultset row. |
|
196 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
197 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
198 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
199 | - * |
|
200 | - * @return mixed The primary key of the row |
|
201 | - */ |
|
202 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
203 | - { |
|
204 | - return (string) $row[ |
|
205 | - $indexType == TableMap::TYPE_NUM |
|
206 | - ? 0 + $offset |
|
207 | - : self::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType) |
|
208 | - ]; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * The class that the tableMap will make instances of. |
|
213 | - * |
|
214 | - * If $withPrefix is true, the returned path |
|
215 | - * uses a dot-path notation which is translated into a path |
|
216 | - * relative to a location on the PHP include_path. |
|
217 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
218 | - * |
|
219 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
220 | - * @return string path.to.ClassName |
|
221 | - */ |
|
222 | - public static function getOMClass($withPrefix = true) |
|
223 | - { |
|
224 | - return $withPrefix ? InstanceTableMap::CLASS_DEFAULT : InstanceTableMap::OM_CLASS; |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Populates an object of the default type or an object that inherit from the default. |
|
229 | - * |
|
230 | - * @param array $row row returned by DataFetcher->fetch(). |
|
231 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
232 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
165 | + } // buildRelations() |
|
166 | + |
|
167 | + /** |
|
168 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
169 | + * |
|
170 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
171 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
172 | + * |
|
173 | + * @param array $row resultset row. |
|
174 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
175 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
176 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
177 | + * |
|
178 | + * @return string The primary key hash of the row |
|
179 | + */ |
|
180 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
181 | + { |
|
182 | + // If the PK cannot be derived from the row, return NULL. |
|
183 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
184 | + return null; |
|
185 | + } |
|
186 | + |
|
187 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Retrieves the primary key from the DB resultset row |
|
192 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
193 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
194 | + * |
|
195 | + * @param array $row resultset row. |
|
196 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
197 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
198 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
199 | + * |
|
200 | + * @return mixed The primary key of the row |
|
201 | + */ |
|
202 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
203 | + { |
|
204 | + return (string) $row[ |
|
205 | + $indexType == TableMap::TYPE_NUM |
|
206 | + ? 0 + $offset |
|
207 | + : self::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType) |
|
208 | + ]; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * The class that the tableMap will make instances of. |
|
213 | + * |
|
214 | + * If $withPrefix is true, the returned path |
|
215 | + * uses a dot-path notation which is translated into a path |
|
216 | + * relative to a location on the PHP include_path. |
|
217 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
218 | + * |
|
219 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
220 | + * @return string path.to.ClassName |
|
221 | + */ |
|
222 | + public static function getOMClass($withPrefix = true) |
|
223 | + { |
|
224 | + return $withPrefix ? InstanceTableMap::CLASS_DEFAULT : InstanceTableMap::OM_CLASS; |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Populates an object of the default type or an object that inherit from the default. |
|
229 | + * |
|
230 | + * @param array $row row returned by DataFetcher->fetch(). |
|
231 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
232 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
233 | 233 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
234 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
235 | - * |
|
236 | - * @throws PropelException Any exceptions caught during processing will be |
|
237 | - * rethrown wrapped into a PropelException. |
|
238 | - * @return array (Instance object, last column rank) |
|
239 | - */ |
|
240 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
241 | - { |
|
242 | - $key = InstanceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
243 | - if (null !== ($obj = InstanceTableMap::getInstanceFromPool($key))) { |
|
244 | - // We no longer rehydrate the object, since this can cause data loss. |
|
245 | - // See http://www.propelorm.org/ticket/509 |
|
246 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
247 | - $col = $offset + InstanceTableMap::NUM_HYDRATE_COLUMNS; |
|
248 | - } else { |
|
249 | - $cls = InstanceTableMap::OM_CLASS; |
|
250 | - /** @var Instance $obj */ |
|
251 | - $obj = new $cls(); |
|
252 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
253 | - InstanceTableMap::addInstanceToPool($obj, $key); |
|
254 | - } |
|
255 | - |
|
256 | - return array($obj, $col); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * The returned array will contain objects of the default type or |
|
261 | - * objects that inherit from the default. |
|
262 | - * |
|
263 | - * @param DataFetcherInterface $dataFetcher |
|
264 | - * @return array |
|
265 | - * @throws PropelException Any exceptions caught during processing will be |
|
266 | - * rethrown wrapped into a PropelException. |
|
267 | - */ |
|
268 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
269 | - { |
|
270 | - $results = array(); |
|
271 | - |
|
272 | - // set the class once to avoid overhead in the loop |
|
273 | - $cls = static::getOMClass(false); |
|
274 | - // populate the object(s) |
|
275 | - while ($row = $dataFetcher->fetch()) { |
|
276 | - $key = InstanceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
277 | - if (null !== ($obj = InstanceTableMap::getInstanceFromPool($key))) { |
|
278 | - // We no longer rehydrate the object, since this can cause data loss. |
|
279 | - // See http://www.propelorm.org/ticket/509 |
|
280 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
281 | - $results[] = $obj; |
|
282 | - } else { |
|
283 | - /** @var Instance $obj */ |
|
284 | - $obj = new $cls(); |
|
285 | - $obj->hydrate($row); |
|
286 | - $results[] = $obj; |
|
287 | - InstanceTableMap::addInstanceToPool($obj, $key); |
|
288 | - } // if key exists |
|
289 | - } |
|
290 | - |
|
291 | - return $results; |
|
292 | - } |
|
293 | - /** |
|
294 | - * Add all the columns needed to create a new object. |
|
295 | - * |
|
296 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
297 | - * XML schema will not be added to the select list and only loaded |
|
298 | - * on demand. |
|
299 | - * |
|
300 | - * @param Criteria $criteria object containing the columns to add. |
|
301 | - * @param string $alias optional table alias |
|
302 | - * @throws PropelException Any exceptions caught during processing will be |
|
303 | - * rethrown wrapped into a PropelException. |
|
304 | - */ |
|
305 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
306 | - { |
|
307 | - if (null === $alias) { |
|
308 | - $criteria->addSelectColumn(InstanceTableMap::COL_NAME); |
|
309 | - } else { |
|
310 | - $criteria->addSelectColumn($alias . '.name'); |
|
311 | - } |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Returns the TableMap related to this object. |
|
316 | - * This method is not needed for general use but a specific application could have a need. |
|
317 | - * @return TableMap |
|
318 | - * @throws PropelException Any exceptions caught during processing will be |
|
319 | - * rethrown wrapped into a PropelException. |
|
320 | - */ |
|
321 | - public static function getTableMap() |
|
322 | - { |
|
323 | - return Propel::getServiceContainer()->getDatabaseMap(InstanceTableMap::DATABASE_NAME)->getTable(InstanceTableMap::TABLE_NAME); |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Add a TableMap instance to the database for this tableMap class. |
|
328 | - */ |
|
329 | - public static function buildTableMap() |
|
330 | - { |
|
331 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(InstanceTableMap::DATABASE_NAME); |
|
332 | - if (!$dbMap->hasTable(InstanceTableMap::TABLE_NAME)) { |
|
333 | - $dbMap->addTableObject(new InstanceTableMap()); |
|
334 | - } |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Performs a DELETE on the database, given a Instance or Criteria object OR a primary key value. |
|
339 | - * |
|
340 | - * @param mixed $values Criteria or Instance object or primary key or array of primary keys |
|
341 | - * which is used to create the DELETE statement |
|
342 | - * @param ConnectionInterface $con the connection to use |
|
343 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
344 | - * if supported by native driver or if emulated using Propel. |
|
345 | - * @throws PropelException Any exceptions caught during processing will be |
|
346 | - * rethrown wrapped into a PropelException. |
|
347 | - */ |
|
348 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
349 | - { |
|
350 | - if (null === $con) { |
|
351 | - $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
352 | - } |
|
353 | - |
|
354 | - if ($values instanceof Criteria) { |
|
355 | - // rename for clarity |
|
356 | - $criteria = $values; |
|
357 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\Instance) { // it's a model object |
|
358 | - // create criteria based on pk values |
|
359 | - $criteria = $values->buildPkeyCriteria(); |
|
360 | - } else { // it's a primary key, or an array of pks |
|
361 | - $criteria = new Criteria(InstanceTableMap::DATABASE_NAME); |
|
362 | - $criteria->add(InstanceTableMap::COL_NAME, (array) $values, Criteria::IN); |
|
363 | - } |
|
364 | - |
|
365 | - $query = InstanceQuery::create()->mergeWith($criteria); |
|
366 | - |
|
367 | - if ($values instanceof Criteria) { |
|
368 | - InstanceTableMap::clearInstancePool(); |
|
369 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
370 | - foreach ((array) $values as $singleval) { |
|
371 | - InstanceTableMap::removeInstanceFromPool($singleval); |
|
372 | - } |
|
373 | - } |
|
374 | - |
|
375 | - return $query->delete($con); |
|
376 | - } |
|
377 | - |
|
378 | - /** |
|
379 | - * Deletes all rows from the instance table. |
|
380 | - * |
|
381 | - * @param ConnectionInterface $con the connection to use |
|
382 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
383 | - */ |
|
384 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
385 | - { |
|
386 | - return InstanceQuery::create()->doDeleteAll($con); |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * Performs an INSERT on the database, given a Instance or Criteria object. |
|
391 | - * |
|
392 | - * @param mixed $criteria Criteria or Instance object containing data that is used to create the INSERT statement. |
|
393 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
394 | - * @return mixed The new primary key. |
|
395 | - * @throws PropelException Any exceptions caught during processing will be |
|
396 | - * rethrown wrapped into a PropelException. |
|
397 | - */ |
|
398 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
399 | - { |
|
400 | - if (null === $con) { |
|
401 | - $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
402 | - } |
|
403 | - |
|
404 | - if ($criteria instanceof Criteria) { |
|
405 | - $criteria = clone $criteria; // rename for clarity |
|
406 | - } else { |
|
407 | - $criteria = $criteria->buildCriteria(); // build Criteria from Instance object |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - // Set the correct dbName |
|
412 | - $query = InstanceQuery::create()->mergeWith($criteria); |
|
413 | - |
|
414 | - // use transaction because $criteria could contain info |
|
415 | - // for more than one table (I guess, conceivably) |
|
416 | - return $con->transaction(function () use ($con, $query) { |
|
417 | - return $query->doInsert($con); |
|
418 | - }); |
|
419 | - } |
|
234 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
235 | + * |
|
236 | + * @throws PropelException Any exceptions caught during processing will be |
|
237 | + * rethrown wrapped into a PropelException. |
|
238 | + * @return array (Instance object, last column rank) |
|
239 | + */ |
|
240 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
241 | + { |
|
242 | + $key = InstanceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
243 | + if (null !== ($obj = InstanceTableMap::getInstanceFromPool($key))) { |
|
244 | + // We no longer rehydrate the object, since this can cause data loss. |
|
245 | + // See http://www.propelorm.org/ticket/509 |
|
246 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
247 | + $col = $offset + InstanceTableMap::NUM_HYDRATE_COLUMNS; |
|
248 | + } else { |
|
249 | + $cls = InstanceTableMap::OM_CLASS; |
|
250 | + /** @var Instance $obj */ |
|
251 | + $obj = new $cls(); |
|
252 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
253 | + InstanceTableMap::addInstanceToPool($obj, $key); |
|
254 | + } |
|
255 | + |
|
256 | + return array($obj, $col); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * The returned array will contain objects of the default type or |
|
261 | + * objects that inherit from the default. |
|
262 | + * |
|
263 | + * @param DataFetcherInterface $dataFetcher |
|
264 | + * @return array |
|
265 | + * @throws PropelException Any exceptions caught during processing will be |
|
266 | + * rethrown wrapped into a PropelException. |
|
267 | + */ |
|
268 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
269 | + { |
|
270 | + $results = array(); |
|
271 | + |
|
272 | + // set the class once to avoid overhead in the loop |
|
273 | + $cls = static::getOMClass(false); |
|
274 | + // populate the object(s) |
|
275 | + while ($row = $dataFetcher->fetch()) { |
|
276 | + $key = InstanceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
277 | + if (null !== ($obj = InstanceTableMap::getInstanceFromPool($key))) { |
|
278 | + // We no longer rehydrate the object, since this can cause data loss. |
|
279 | + // See http://www.propelorm.org/ticket/509 |
|
280 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
281 | + $results[] = $obj; |
|
282 | + } else { |
|
283 | + /** @var Instance $obj */ |
|
284 | + $obj = new $cls(); |
|
285 | + $obj->hydrate($row); |
|
286 | + $results[] = $obj; |
|
287 | + InstanceTableMap::addInstanceToPool($obj, $key); |
|
288 | + } // if key exists |
|
289 | + } |
|
290 | + |
|
291 | + return $results; |
|
292 | + } |
|
293 | + /** |
|
294 | + * Add all the columns needed to create a new object. |
|
295 | + * |
|
296 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
297 | + * XML schema will not be added to the select list and only loaded |
|
298 | + * on demand. |
|
299 | + * |
|
300 | + * @param Criteria $criteria object containing the columns to add. |
|
301 | + * @param string $alias optional table alias |
|
302 | + * @throws PropelException Any exceptions caught during processing will be |
|
303 | + * rethrown wrapped into a PropelException. |
|
304 | + */ |
|
305 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
306 | + { |
|
307 | + if (null === $alias) { |
|
308 | + $criteria->addSelectColumn(InstanceTableMap::COL_NAME); |
|
309 | + } else { |
|
310 | + $criteria->addSelectColumn($alias . '.name'); |
|
311 | + } |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Returns the TableMap related to this object. |
|
316 | + * This method is not needed for general use but a specific application could have a need. |
|
317 | + * @return TableMap |
|
318 | + * @throws PropelException Any exceptions caught during processing will be |
|
319 | + * rethrown wrapped into a PropelException. |
|
320 | + */ |
|
321 | + public static function getTableMap() |
|
322 | + { |
|
323 | + return Propel::getServiceContainer()->getDatabaseMap(InstanceTableMap::DATABASE_NAME)->getTable(InstanceTableMap::TABLE_NAME); |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Add a TableMap instance to the database for this tableMap class. |
|
328 | + */ |
|
329 | + public static function buildTableMap() |
|
330 | + { |
|
331 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(InstanceTableMap::DATABASE_NAME); |
|
332 | + if (!$dbMap->hasTable(InstanceTableMap::TABLE_NAME)) { |
|
333 | + $dbMap->addTableObject(new InstanceTableMap()); |
|
334 | + } |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Performs a DELETE on the database, given a Instance or Criteria object OR a primary key value. |
|
339 | + * |
|
340 | + * @param mixed $values Criteria or Instance object or primary key or array of primary keys |
|
341 | + * which is used to create the DELETE statement |
|
342 | + * @param ConnectionInterface $con the connection to use |
|
343 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
344 | + * if supported by native driver or if emulated using Propel. |
|
345 | + * @throws PropelException Any exceptions caught during processing will be |
|
346 | + * rethrown wrapped into a PropelException. |
|
347 | + */ |
|
348 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
349 | + { |
|
350 | + if (null === $con) { |
|
351 | + $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
352 | + } |
|
353 | + |
|
354 | + if ($values instanceof Criteria) { |
|
355 | + // rename for clarity |
|
356 | + $criteria = $values; |
|
357 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\Instance) { // it's a model object |
|
358 | + // create criteria based on pk values |
|
359 | + $criteria = $values->buildPkeyCriteria(); |
|
360 | + } else { // it's a primary key, or an array of pks |
|
361 | + $criteria = new Criteria(InstanceTableMap::DATABASE_NAME); |
|
362 | + $criteria->add(InstanceTableMap::COL_NAME, (array) $values, Criteria::IN); |
|
363 | + } |
|
364 | + |
|
365 | + $query = InstanceQuery::create()->mergeWith($criteria); |
|
366 | + |
|
367 | + if ($values instanceof Criteria) { |
|
368 | + InstanceTableMap::clearInstancePool(); |
|
369 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
370 | + foreach ((array) $values as $singleval) { |
|
371 | + InstanceTableMap::removeInstanceFromPool($singleval); |
|
372 | + } |
|
373 | + } |
|
374 | + |
|
375 | + return $query->delete($con); |
|
376 | + } |
|
377 | + |
|
378 | + /** |
|
379 | + * Deletes all rows from the instance table. |
|
380 | + * |
|
381 | + * @param ConnectionInterface $con the connection to use |
|
382 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
383 | + */ |
|
384 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
385 | + { |
|
386 | + return InstanceQuery::create()->doDeleteAll($con); |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * Performs an INSERT on the database, given a Instance or Criteria object. |
|
391 | + * |
|
392 | + * @param mixed $criteria Criteria or Instance object containing data that is used to create the INSERT statement. |
|
393 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
394 | + * @return mixed The new primary key. |
|
395 | + * @throws PropelException Any exceptions caught during processing will be |
|
396 | + * rethrown wrapped into a PropelException. |
|
397 | + */ |
|
398 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
399 | + { |
|
400 | + if (null === $con) { |
|
401 | + $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
402 | + } |
|
403 | + |
|
404 | + if ($criteria instanceof Criteria) { |
|
405 | + $criteria = clone $criteria; // rename for clarity |
|
406 | + } else { |
|
407 | + $criteria = $criteria->buildCriteria(); // build Criteria from Instance object |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + // Set the correct dbName |
|
412 | + $query = InstanceQuery::create()->mergeWith($criteria); |
|
413 | + |
|
414 | + // use transaction because $criteria could contain info |
|
415 | + // for more than one table (I guess, conceivably) |
|
416 | + return $con->transaction(function () use ($con, $query) { |
|
417 | + return $query->doInsert($con); |
|
418 | + }); |
|
419 | + } |
|
420 | 420 | |
421 | 421 | } // InstanceTableMap |
422 | 422 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * first dimension keys are the type constants |
88 | 88 | * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
89 | 89 | */ |
90 | - protected static $fieldNames = array ( |
|
91 | - self::TYPE_PHPNAME => array('Name', ), |
|
92 | - self::TYPE_CAMELNAME => array('name', ), |
|
93 | - self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME, ), |
|
94 | - self::TYPE_FIELDNAME => array('name', ), |
|
95 | - self::TYPE_NUM => array(0, ) |
|
90 | + protected static $fieldNames = array( |
|
91 | + self::TYPE_PHPNAME => array('Name',), |
|
92 | + self::TYPE_CAMELNAME => array('name',), |
|
93 | + self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME,), |
|
94 | + self::TYPE_FIELDNAME => array('name',), |
|
95 | + self::TYPE_NUM => array(0,) |
|
96 | 96 | ); |
97 | 97 | |
98 | 98 | /** |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * first dimension keys are the type constants |
102 | 102 | * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
103 | 103 | */ |
104 | - protected static $fieldKeys = array ( |
|
105 | - self::TYPE_PHPNAME => array('Name' => 0, ), |
|
106 | - self::TYPE_CAMELNAME => array('name' => 0, ), |
|
107 | - self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME => 0, ), |
|
108 | - self::TYPE_FIELDNAME => array('name' => 0, ), |
|
109 | - self::TYPE_NUM => array(0, ) |
|
104 | + protected static $fieldKeys = array( |
|
105 | + self::TYPE_PHPNAME => array('Name' => 0,), |
|
106 | + self::TYPE_CAMELNAME => array('name' => 0,), |
|
107 | + self::TYPE_COLNAME => array(InstanceTableMap::COL_NAME => 0,), |
|
108 | + self::TYPE_FIELDNAME => array('name' => 0,), |
|
109 | + self::TYPE_NUM => array(0,) |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | /** |
@@ -134,30 +134,30 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function buildRelations() |
136 | 136 | { |
137 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::ONE_TO_MANY, array ( |
|
137 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::ONE_TO_MANY, array( |
|
138 | 138 | 0 => |
139 | - array ( |
|
139 | + array( |
|
140 | 140 | 0 => ':instance_name', |
141 | 141 | 1 => ':name', |
142 | 142 | ), |
143 | 143 | ), null, null, 'Users', false); |
144 | - $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
144 | + $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array( |
|
145 | 145 | 0 => |
146 | - array ( |
|
146 | + array( |
|
147 | 147 | 0 => ':instance_name', |
148 | 148 | 1 => ':name', |
149 | 149 | ), |
150 | 150 | ), null, null, 'Connections', false); |
151 | - $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::ONE_TO_MANY, array ( |
|
151 | + $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::ONE_TO_MANY, array( |
|
152 | 152 | 0 => |
153 | - array ( |
|
153 | + array( |
|
154 | 154 | 0 => ':instance_name', |
155 | 155 | 1 => ':name', |
156 | 156 | ), |
157 | 157 | ), null, null, 'Channels', false); |
158 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
158 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array( |
|
159 | 159 | 0 => |
160 | - array ( |
|
160 | + array( |
|
161 | 161 | 0 => ':instance_name', |
162 | 162 | 1 => ':name', |
163 | 163 | ), |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | |
414 | 414 | // use transaction because $criteria could contain info |
415 | 415 | // for more than one table (I guess, conceivably) |
416 | - return $con->transaction(function () use ($con, $query) { |
|
416 | + return $con->transaction(function() use ($con, $query) { |
|
417 | 417 | return $query->doInsert($con); |
418 | 418 | }); |
419 | 419 | } |
@@ -28,456 +28,456 @@ |
||
28 | 28 | */ |
29 | 29 | class SubscriptionTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.SubscriptionTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'subscription'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Subscription'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Subscription'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 9; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 9; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'subscription.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'subscription.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the user_id field |
|
86 | - */ |
|
87 | - const COL_USER_ID = 'subscription.user_id'; |
|
88 | - |
|
89 | - /** |
|
90 | - * the column name for the channel_id field |
|
91 | - */ |
|
92 | - const COL_CHANNEL_ID = 'subscription.channel_id'; |
|
93 | - |
|
94 | - /** |
|
95 | - * the column name for the subscription_id field |
|
96 | - */ |
|
97 | - const COL_SUBSCRIPTION_ID = 'subscription.subscription_id'; |
|
98 | - |
|
99 | - /** |
|
100 | - * the column name for the started field |
|
101 | - */ |
|
102 | - const COL_STARTED = 'subscription.started'; |
|
103 | - |
|
104 | - /** |
|
105 | - * the column name for the stopped field |
|
106 | - */ |
|
107 | - const COL_STOPPED = 'subscription.stopped'; |
|
108 | - |
|
109 | - /** |
|
110 | - * the column name for the title field |
|
111 | - */ |
|
112 | - const COL_TITLE = 'subscription.title'; |
|
113 | - |
|
114 | - /** |
|
115 | - * the column name for the service field |
|
116 | - */ |
|
117 | - const COL_SERVICE = 'subscription.service'; |
|
118 | - |
|
119 | - /** |
|
120 | - * The default string format for model objects of the related table |
|
121 | - */ |
|
122 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
123 | - |
|
124 | - /** |
|
125 | - * holds an array of fieldnames |
|
126 | - * |
|
127 | - * first dimension keys are the type constants |
|
128 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
129 | - */ |
|
130 | - protected static $fieldNames = array ( |
|
131 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'ChannelId', 'SubscriptionId', 'Started', 'Stopped', 'Title', 'Service', ), |
|
132 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'channelId', 'subscriptionId', 'started', 'stopped', 'title', 'service', ), |
|
133 | - self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID, SubscriptionTableMap::COL_INSTANCE_NAME, SubscriptionTableMap::COL_USER_ID, SubscriptionTableMap::COL_CHANNEL_ID, SubscriptionTableMap::COL_SUBSCRIPTION_ID, SubscriptionTableMap::COL_STARTED, SubscriptionTableMap::COL_STOPPED, SubscriptionTableMap::COL_TITLE, SubscriptionTableMap::COL_SERVICE, ), |
|
134 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'channel_id', 'subscription_id', 'started', 'stopped', 'title', 'service', ), |
|
135 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) |
|
136 | - ); |
|
137 | - |
|
138 | - /** |
|
139 | - * holds an array of keys for quick access to the fieldnames array |
|
140 | - * |
|
141 | - * first dimension keys are the type constants |
|
142 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
143 | - */ |
|
144 | - protected static $fieldKeys = array ( |
|
145 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'ChannelId' => 3, 'SubscriptionId' => 4, 'Started' => 5, 'Stopped' => 6, 'Title' => 7, 'Service' => 8, ), |
|
146 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'channelId' => 3, 'subscriptionId' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8, ), |
|
147 | - self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID => 0, SubscriptionTableMap::COL_INSTANCE_NAME => 1, SubscriptionTableMap::COL_USER_ID => 2, SubscriptionTableMap::COL_CHANNEL_ID => 3, SubscriptionTableMap::COL_SUBSCRIPTION_ID => 4, SubscriptionTableMap::COL_STARTED => 5, SubscriptionTableMap::COL_STOPPED => 6, SubscriptionTableMap::COL_TITLE => 7, SubscriptionTableMap::COL_SERVICE => 8, ), |
|
148 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'channel_id' => 3, 'subscription_id' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8, ), |
|
149 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) |
|
150 | - ); |
|
151 | - |
|
152 | - /** |
|
153 | - * Initialize the table attributes and columns |
|
154 | - * Relations are not initialized by this method since they are lazy loaded |
|
155 | - * |
|
156 | - * @return void |
|
157 | - * @throws PropelException |
|
158 | - */ |
|
159 | - public function initialize() |
|
160 | - { |
|
161 | - // attributes |
|
162 | - $this->setName('subscription'); |
|
163 | - $this->setPhpName('Subscription'); |
|
164 | - $this->setIdentifierQuoting(false); |
|
165 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\Subscription'); |
|
166 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
167 | - $this->setUseIdGenerator(true); |
|
168 | - // columns |
|
169 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
170 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
171 | - $this->addForeignKey('user_id', 'UserId', 'INTEGER', 'user', 'id', false, null, null); |
|
172 | - $this->addForeignKey('channel_id', 'ChannelId', 'INTEGER', 'channel', 'id', true, null, null); |
|
173 | - $this->addColumn('subscription_id', 'SubscriptionId', 'INTEGER', true, null, null); |
|
174 | - $this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
|
175 | - $this->addColumn('stopped', 'Stopped', 'TIMESTAMP', false, null, null); |
|
176 | - $this->addColumn('title', 'Title', 'VARCHAR', true, 255, null); |
|
177 | - $this->addColumn('service', 'Service', 'VARCHAR', true, 255, null); |
|
178 | - } // initialize() |
|
179 | - |
|
180 | - /** |
|
181 | - * Build the RelationMap objects for this table relationships |
|
182 | - */ |
|
183 | - public function buildRelations() |
|
184 | - { |
|
185 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.SubscriptionTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'subscription'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Subscription'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Subscription'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 9; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 9; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'subscription.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'subscription.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the user_id field |
|
86 | + */ |
|
87 | + const COL_USER_ID = 'subscription.user_id'; |
|
88 | + |
|
89 | + /** |
|
90 | + * the column name for the channel_id field |
|
91 | + */ |
|
92 | + const COL_CHANNEL_ID = 'subscription.channel_id'; |
|
93 | + |
|
94 | + /** |
|
95 | + * the column name for the subscription_id field |
|
96 | + */ |
|
97 | + const COL_SUBSCRIPTION_ID = 'subscription.subscription_id'; |
|
98 | + |
|
99 | + /** |
|
100 | + * the column name for the started field |
|
101 | + */ |
|
102 | + const COL_STARTED = 'subscription.started'; |
|
103 | + |
|
104 | + /** |
|
105 | + * the column name for the stopped field |
|
106 | + */ |
|
107 | + const COL_STOPPED = 'subscription.stopped'; |
|
108 | + |
|
109 | + /** |
|
110 | + * the column name for the title field |
|
111 | + */ |
|
112 | + const COL_TITLE = 'subscription.title'; |
|
113 | + |
|
114 | + /** |
|
115 | + * the column name for the service field |
|
116 | + */ |
|
117 | + const COL_SERVICE = 'subscription.service'; |
|
118 | + |
|
119 | + /** |
|
120 | + * The default string format for model objects of the related table |
|
121 | + */ |
|
122 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
123 | + |
|
124 | + /** |
|
125 | + * holds an array of fieldnames |
|
126 | + * |
|
127 | + * first dimension keys are the type constants |
|
128 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
129 | + */ |
|
130 | + protected static $fieldNames = array ( |
|
131 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'ChannelId', 'SubscriptionId', 'Started', 'Stopped', 'Title', 'Service', ), |
|
132 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'channelId', 'subscriptionId', 'started', 'stopped', 'title', 'service', ), |
|
133 | + self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID, SubscriptionTableMap::COL_INSTANCE_NAME, SubscriptionTableMap::COL_USER_ID, SubscriptionTableMap::COL_CHANNEL_ID, SubscriptionTableMap::COL_SUBSCRIPTION_ID, SubscriptionTableMap::COL_STARTED, SubscriptionTableMap::COL_STOPPED, SubscriptionTableMap::COL_TITLE, SubscriptionTableMap::COL_SERVICE, ), |
|
134 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'channel_id', 'subscription_id', 'started', 'stopped', 'title', 'service', ), |
|
135 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) |
|
136 | + ); |
|
137 | + |
|
138 | + /** |
|
139 | + * holds an array of keys for quick access to the fieldnames array |
|
140 | + * |
|
141 | + * first dimension keys are the type constants |
|
142 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
143 | + */ |
|
144 | + protected static $fieldKeys = array ( |
|
145 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'ChannelId' => 3, 'SubscriptionId' => 4, 'Started' => 5, 'Stopped' => 6, 'Title' => 7, 'Service' => 8, ), |
|
146 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'channelId' => 3, 'subscriptionId' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8, ), |
|
147 | + self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID => 0, SubscriptionTableMap::COL_INSTANCE_NAME => 1, SubscriptionTableMap::COL_USER_ID => 2, SubscriptionTableMap::COL_CHANNEL_ID => 3, SubscriptionTableMap::COL_SUBSCRIPTION_ID => 4, SubscriptionTableMap::COL_STARTED => 5, SubscriptionTableMap::COL_STOPPED => 6, SubscriptionTableMap::COL_TITLE => 7, SubscriptionTableMap::COL_SERVICE => 8, ), |
|
148 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'channel_id' => 3, 'subscription_id' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8, ), |
|
149 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) |
|
150 | + ); |
|
151 | + |
|
152 | + /** |
|
153 | + * Initialize the table attributes and columns |
|
154 | + * Relations are not initialized by this method since they are lazy loaded |
|
155 | + * |
|
156 | + * @return void |
|
157 | + * @throws PropelException |
|
158 | + */ |
|
159 | + public function initialize() |
|
160 | + { |
|
161 | + // attributes |
|
162 | + $this->setName('subscription'); |
|
163 | + $this->setPhpName('Subscription'); |
|
164 | + $this->setIdentifierQuoting(false); |
|
165 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\Subscription'); |
|
166 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
167 | + $this->setUseIdGenerator(true); |
|
168 | + // columns |
|
169 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
170 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
171 | + $this->addForeignKey('user_id', 'UserId', 'INTEGER', 'user', 'id', false, null, null); |
|
172 | + $this->addForeignKey('channel_id', 'ChannelId', 'INTEGER', 'channel', 'id', true, null, null); |
|
173 | + $this->addColumn('subscription_id', 'SubscriptionId', 'INTEGER', true, null, null); |
|
174 | + $this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
|
175 | + $this->addColumn('stopped', 'Stopped', 'TIMESTAMP', false, null, null); |
|
176 | + $this->addColumn('title', 'Title', 'VARCHAR', true, 255, null); |
|
177 | + $this->addColumn('service', 'Service', 'VARCHAR', true, 255, null); |
|
178 | + } // initialize() |
|
179 | + |
|
180 | + /** |
|
181 | + * Build the RelationMap objects for this table relationships |
|
182 | + */ |
|
183 | + public function buildRelations() |
|
184 | + { |
|
185 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
186 | 186 | 0 => |
187 | 187 | array ( |
188 | - 0 => ':instance_name', |
|
189 | - 1 => ':name', |
|
188 | + 0 => ':instance_name', |
|
189 | + 1 => ':name', |
|
190 | 190 | ), |
191 | 191 | ), null, null, null, false); |
192 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
192 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
193 | 193 | 0 => |
194 | 194 | array ( |
195 | - 0 => ':user_id', |
|
196 | - 1 => ':id', |
|
195 | + 0 => ':user_id', |
|
196 | + 1 => ':id', |
|
197 | 197 | ), |
198 | 198 | ), null, null, null, false); |
199 | - $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::MANY_TO_ONE, array ( |
|
199 | + $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::MANY_TO_ONE, array ( |
|
200 | 200 | 0 => |
201 | 201 | array ( |
202 | - 0 => ':channel_id', |
|
203 | - 1 => ':id', |
|
202 | + 0 => ':channel_id', |
|
203 | + 1 => ':id', |
|
204 | 204 | ), |
205 | 205 | ), null, null, null, false); |
206 | - } // buildRelations() |
|
207 | - |
|
208 | - /** |
|
209 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
210 | - * |
|
211 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
212 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
213 | - * |
|
214 | - * @param array $row resultset row. |
|
215 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
216 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
217 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
218 | - * |
|
219 | - * @return string The primary key hash of the row |
|
220 | - */ |
|
221 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
222 | - { |
|
223 | - // If the PK cannot be derived from the row, return NULL. |
|
224 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
225 | - return null; |
|
226 | - } |
|
227 | - |
|
228 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Retrieves the primary key from the DB resultset row |
|
233 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
234 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
235 | - * |
|
236 | - * @param array $row resultset row. |
|
237 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
238 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
239 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
240 | - * |
|
241 | - * @return mixed The primary key of the row |
|
242 | - */ |
|
243 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
244 | - { |
|
245 | - return (int) $row[ |
|
246 | - $indexType == TableMap::TYPE_NUM |
|
247 | - ? 0 + $offset |
|
248 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
249 | - ]; |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * The class that the tableMap will make instances of. |
|
254 | - * |
|
255 | - * If $withPrefix is true, the returned path |
|
256 | - * uses a dot-path notation which is translated into a path |
|
257 | - * relative to a location on the PHP include_path. |
|
258 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
259 | - * |
|
260 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
261 | - * @return string path.to.ClassName |
|
262 | - */ |
|
263 | - public static function getOMClass($withPrefix = true) |
|
264 | - { |
|
265 | - return $withPrefix ? SubscriptionTableMap::CLASS_DEFAULT : SubscriptionTableMap::OM_CLASS; |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Populates an object of the default type or an object that inherit from the default. |
|
270 | - * |
|
271 | - * @param array $row row returned by DataFetcher->fetch(). |
|
272 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
273 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
206 | + } // buildRelations() |
|
207 | + |
|
208 | + /** |
|
209 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
210 | + * |
|
211 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
212 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
213 | + * |
|
214 | + * @param array $row resultset row. |
|
215 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
216 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
217 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
218 | + * |
|
219 | + * @return string The primary key hash of the row |
|
220 | + */ |
|
221 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
222 | + { |
|
223 | + // If the PK cannot be derived from the row, return NULL. |
|
224 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
225 | + return null; |
|
226 | + } |
|
227 | + |
|
228 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Retrieves the primary key from the DB resultset row |
|
233 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
234 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
235 | + * |
|
236 | + * @param array $row resultset row. |
|
237 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
238 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
239 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
240 | + * |
|
241 | + * @return mixed The primary key of the row |
|
242 | + */ |
|
243 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
244 | + { |
|
245 | + return (int) $row[ |
|
246 | + $indexType == TableMap::TYPE_NUM |
|
247 | + ? 0 + $offset |
|
248 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
249 | + ]; |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * The class that the tableMap will make instances of. |
|
254 | + * |
|
255 | + * If $withPrefix is true, the returned path |
|
256 | + * uses a dot-path notation which is translated into a path |
|
257 | + * relative to a location on the PHP include_path. |
|
258 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
259 | + * |
|
260 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
261 | + * @return string path.to.ClassName |
|
262 | + */ |
|
263 | + public static function getOMClass($withPrefix = true) |
|
264 | + { |
|
265 | + return $withPrefix ? SubscriptionTableMap::CLASS_DEFAULT : SubscriptionTableMap::OM_CLASS; |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Populates an object of the default type or an object that inherit from the default. |
|
270 | + * |
|
271 | + * @param array $row row returned by DataFetcher->fetch(). |
|
272 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
273 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
274 | 274 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
275 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
276 | - * |
|
277 | - * @throws PropelException Any exceptions caught during processing will be |
|
278 | - * rethrown wrapped into a PropelException. |
|
279 | - * @return array (Subscription object, last column rank) |
|
280 | - */ |
|
281 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
282 | - { |
|
283 | - $key = SubscriptionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
284 | - if (null !== ($obj = SubscriptionTableMap::getInstanceFromPool($key))) { |
|
285 | - // We no longer rehydrate the object, since this can cause data loss. |
|
286 | - // See http://www.propelorm.org/ticket/509 |
|
287 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
288 | - $col = $offset + SubscriptionTableMap::NUM_HYDRATE_COLUMNS; |
|
289 | - } else { |
|
290 | - $cls = SubscriptionTableMap::OM_CLASS; |
|
291 | - /** @var Subscription $obj */ |
|
292 | - $obj = new $cls(); |
|
293 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
294 | - SubscriptionTableMap::addInstanceToPool($obj, $key); |
|
295 | - } |
|
296 | - |
|
297 | - return array($obj, $col); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * The returned array will contain objects of the default type or |
|
302 | - * objects that inherit from the default. |
|
303 | - * |
|
304 | - * @param DataFetcherInterface $dataFetcher |
|
305 | - * @return array |
|
306 | - * @throws PropelException Any exceptions caught during processing will be |
|
307 | - * rethrown wrapped into a PropelException. |
|
308 | - */ |
|
309 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
310 | - { |
|
311 | - $results = array(); |
|
312 | - |
|
313 | - // set the class once to avoid overhead in the loop |
|
314 | - $cls = static::getOMClass(false); |
|
315 | - // populate the object(s) |
|
316 | - while ($row = $dataFetcher->fetch()) { |
|
317 | - $key = SubscriptionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
318 | - if (null !== ($obj = SubscriptionTableMap::getInstanceFromPool($key))) { |
|
319 | - // We no longer rehydrate the object, since this can cause data loss. |
|
320 | - // See http://www.propelorm.org/ticket/509 |
|
321 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
322 | - $results[] = $obj; |
|
323 | - } else { |
|
324 | - /** @var Subscription $obj */ |
|
325 | - $obj = new $cls(); |
|
326 | - $obj->hydrate($row); |
|
327 | - $results[] = $obj; |
|
328 | - SubscriptionTableMap::addInstanceToPool($obj, $key); |
|
329 | - } // if key exists |
|
330 | - } |
|
331 | - |
|
332 | - return $results; |
|
333 | - } |
|
334 | - /** |
|
335 | - * Add all the columns needed to create a new object. |
|
336 | - * |
|
337 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
338 | - * XML schema will not be added to the select list and only loaded |
|
339 | - * on demand. |
|
340 | - * |
|
341 | - * @param Criteria $criteria object containing the columns to add. |
|
342 | - * @param string $alias optional table alias |
|
343 | - * @throws PropelException Any exceptions caught during processing will be |
|
344 | - * rethrown wrapped into a PropelException. |
|
345 | - */ |
|
346 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
347 | - { |
|
348 | - if (null === $alias) { |
|
349 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_ID); |
|
350 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_INSTANCE_NAME); |
|
351 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_USER_ID); |
|
352 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_CHANNEL_ID); |
|
353 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_SUBSCRIPTION_ID); |
|
354 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_STARTED); |
|
355 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_STOPPED); |
|
356 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_TITLE); |
|
357 | - $criteria->addSelectColumn(SubscriptionTableMap::COL_SERVICE); |
|
358 | - } else { |
|
359 | - $criteria->addSelectColumn($alias . '.id'); |
|
360 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
361 | - $criteria->addSelectColumn($alias . '.user_id'); |
|
362 | - $criteria->addSelectColumn($alias . '.channel_id'); |
|
363 | - $criteria->addSelectColumn($alias . '.subscription_id'); |
|
364 | - $criteria->addSelectColumn($alias . '.started'); |
|
365 | - $criteria->addSelectColumn($alias . '.stopped'); |
|
366 | - $criteria->addSelectColumn($alias . '.title'); |
|
367 | - $criteria->addSelectColumn($alias . '.service'); |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Returns the TableMap related to this object. |
|
373 | - * This method is not needed for general use but a specific application could have a need. |
|
374 | - * @return TableMap |
|
375 | - * @throws PropelException Any exceptions caught during processing will be |
|
376 | - * rethrown wrapped into a PropelException. |
|
377 | - */ |
|
378 | - public static function getTableMap() |
|
379 | - { |
|
380 | - return Propel::getServiceContainer()->getDatabaseMap(SubscriptionTableMap::DATABASE_NAME)->getTable(SubscriptionTableMap::TABLE_NAME); |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Add a TableMap instance to the database for this tableMap class. |
|
385 | - */ |
|
386 | - public static function buildTableMap() |
|
387 | - { |
|
388 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(SubscriptionTableMap::DATABASE_NAME); |
|
389 | - if (!$dbMap->hasTable(SubscriptionTableMap::TABLE_NAME)) { |
|
390 | - $dbMap->addTableObject(new SubscriptionTableMap()); |
|
391 | - } |
|
392 | - } |
|
393 | - |
|
394 | - /** |
|
395 | - * Performs a DELETE on the database, given a Subscription or Criteria object OR a primary key value. |
|
396 | - * |
|
397 | - * @param mixed $values Criteria or Subscription object or primary key or array of primary keys |
|
398 | - * which is used to create the DELETE statement |
|
399 | - * @param ConnectionInterface $con the connection to use |
|
400 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
401 | - * if supported by native driver or if emulated using Propel. |
|
402 | - * @throws PropelException Any exceptions caught during processing will be |
|
403 | - * rethrown wrapped into a PropelException. |
|
404 | - */ |
|
405 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
406 | - { |
|
407 | - if (null === $con) { |
|
408 | - $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
409 | - } |
|
410 | - |
|
411 | - if ($values instanceof Criteria) { |
|
412 | - // rename for clarity |
|
413 | - $criteria = $values; |
|
414 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\Subscription) { // it's a model object |
|
415 | - // create criteria based on pk values |
|
416 | - $criteria = $values->buildPkeyCriteria(); |
|
417 | - } else { // it's a primary key, or an array of pks |
|
418 | - $criteria = new Criteria(SubscriptionTableMap::DATABASE_NAME); |
|
419 | - $criteria->add(SubscriptionTableMap::COL_ID, (array) $values, Criteria::IN); |
|
420 | - } |
|
421 | - |
|
422 | - $query = SubscriptionQuery::create()->mergeWith($criteria); |
|
423 | - |
|
424 | - if ($values instanceof Criteria) { |
|
425 | - SubscriptionTableMap::clearInstancePool(); |
|
426 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
427 | - foreach ((array) $values as $singleval) { |
|
428 | - SubscriptionTableMap::removeInstanceFromPool($singleval); |
|
429 | - } |
|
430 | - } |
|
431 | - |
|
432 | - return $query->delete($con); |
|
433 | - } |
|
434 | - |
|
435 | - /** |
|
436 | - * Deletes all rows from the subscription table. |
|
437 | - * |
|
438 | - * @param ConnectionInterface $con the connection to use |
|
439 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
440 | - */ |
|
441 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
442 | - { |
|
443 | - return SubscriptionQuery::create()->doDeleteAll($con); |
|
444 | - } |
|
445 | - |
|
446 | - /** |
|
447 | - * Performs an INSERT on the database, given a Subscription or Criteria object. |
|
448 | - * |
|
449 | - * @param mixed $criteria Criteria or Subscription object containing data that is used to create the INSERT statement. |
|
450 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
451 | - * @return mixed The new primary key. |
|
452 | - * @throws PropelException Any exceptions caught during processing will be |
|
453 | - * rethrown wrapped into a PropelException. |
|
454 | - */ |
|
455 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
456 | - { |
|
457 | - if (null === $con) { |
|
458 | - $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
459 | - } |
|
460 | - |
|
461 | - if ($criteria instanceof Criteria) { |
|
462 | - $criteria = clone $criteria; // rename for clarity |
|
463 | - } else { |
|
464 | - $criteria = $criteria->buildCriteria(); // build Criteria from Subscription object |
|
465 | - } |
|
466 | - |
|
467 | - if ($criteria->containsKey(SubscriptionTableMap::COL_ID) && $criteria->keyContainsValue(SubscriptionTableMap::COL_ID) ) { |
|
468 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.SubscriptionTableMap::COL_ID.')'); |
|
469 | - } |
|
470 | - |
|
471 | - |
|
472 | - // Set the correct dbName |
|
473 | - $query = SubscriptionQuery::create()->mergeWith($criteria); |
|
474 | - |
|
475 | - // use transaction because $criteria could contain info |
|
476 | - // for more than one table (I guess, conceivably) |
|
477 | - return $con->transaction(function () use ($con, $query) { |
|
478 | - return $query->doInsert($con); |
|
479 | - }); |
|
480 | - } |
|
275 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
276 | + * |
|
277 | + * @throws PropelException Any exceptions caught during processing will be |
|
278 | + * rethrown wrapped into a PropelException. |
|
279 | + * @return array (Subscription object, last column rank) |
|
280 | + */ |
|
281 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
282 | + { |
|
283 | + $key = SubscriptionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
284 | + if (null !== ($obj = SubscriptionTableMap::getInstanceFromPool($key))) { |
|
285 | + // We no longer rehydrate the object, since this can cause data loss. |
|
286 | + // See http://www.propelorm.org/ticket/509 |
|
287 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
288 | + $col = $offset + SubscriptionTableMap::NUM_HYDRATE_COLUMNS; |
|
289 | + } else { |
|
290 | + $cls = SubscriptionTableMap::OM_CLASS; |
|
291 | + /** @var Subscription $obj */ |
|
292 | + $obj = new $cls(); |
|
293 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
294 | + SubscriptionTableMap::addInstanceToPool($obj, $key); |
|
295 | + } |
|
296 | + |
|
297 | + return array($obj, $col); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * The returned array will contain objects of the default type or |
|
302 | + * objects that inherit from the default. |
|
303 | + * |
|
304 | + * @param DataFetcherInterface $dataFetcher |
|
305 | + * @return array |
|
306 | + * @throws PropelException Any exceptions caught during processing will be |
|
307 | + * rethrown wrapped into a PropelException. |
|
308 | + */ |
|
309 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
310 | + { |
|
311 | + $results = array(); |
|
312 | + |
|
313 | + // set the class once to avoid overhead in the loop |
|
314 | + $cls = static::getOMClass(false); |
|
315 | + // populate the object(s) |
|
316 | + while ($row = $dataFetcher->fetch()) { |
|
317 | + $key = SubscriptionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
318 | + if (null !== ($obj = SubscriptionTableMap::getInstanceFromPool($key))) { |
|
319 | + // We no longer rehydrate the object, since this can cause data loss. |
|
320 | + // See http://www.propelorm.org/ticket/509 |
|
321 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
322 | + $results[] = $obj; |
|
323 | + } else { |
|
324 | + /** @var Subscription $obj */ |
|
325 | + $obj = new $cls(); |
|
326 | + $obj->hydrate($row); |
|
327 | + $results[] = $obj; |
|
328 | + SubscriptionTableMap::addInstanceToPool($obj, $key); |
|
329 | + } // if key exists |
|
330 | + } |
|
331 | + |
|
332 | + return $results; |
|
333 | + } |
|
334 | + /** |
|
335 | + * Add all the columns needed to create a new object. |
|
336 | + * |
|
337 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
338 | + * XML schema will not be added to the select list and only loaded |
|
339 | + * on demand. |
|
340 | + * |
|
341 | + * @param Criteria $criteria object containing the columns to add. |
|
342 | + * @param string $alias optional table alias |
|
343 | + * @throws PropelException Any exceptions caught during processing will be |
|
344 | + * rethrown wrapped into a PropelException. |
|
345 | + */ |
|
346 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
347 | + { |
|
348 | + if (null === $alias) { |
|
349 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_ID); |
|
350 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_INSTANCE_NAME); |
|
351 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_USER_ID); |
|
352 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_CHANNEL_ID); |
|
353 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_SUBSCRIPTION_ID); |
|
354 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_STARTED); |
|
355 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_STOPPED); |
|
356 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_TITLE); |
|
357 | + $criteria->addSelectColumn(SubscriptionTableMap::COL_SERVICE); |
|
358 | + } else { |
|
359 | + $criteria->addSelectColumn($alias . '.id'); |
|
360 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
361 | + $criteria->addSelectColumn($alias . '.user_id'); |
|
362 | + $criteria->addSelectColumn($alias . '.channel_id'); |
|
363 | + $criteria->addSelectColumn($alias . '.subscription_id'); |
|
364 | + $criteria->addSelectColumn($alias . '.started'); |
|
365 | + $criteria->addSelectColumn($alias . '.stopped'); |
|
366 | + $criteria->addSelectColumn($alias . '.title'); |
|
367 | + $criteria->addSelectColumn($alias . '.service'); |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Returns the TableMap related to this object. |
|
373 | + * This method is not needed for general use but a specific application could have a need. |
|
374 | + * @return TableMap |
|
375 | + * @throws PropelException Any exceptions caught during processing will be |
|
376 | + * rethrown wrapped into a PropelException. |
|
377 | + */ |
|
378 | + public static function getTableMap() |
|
379 | + { |
|
380 | + return Propel::getServiceContainer()->getDatabaseMap(SubscriptionTableMap::DATABASE_NAME)->getTable(SubscriptionTableMap::TABLE_NAME); |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Add a TableMap instance to the database for this tableMap class. |
|
385 | + */ |
|
386 | + public static function buildTableMap() |
|
387 | + { |
|
388 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SubscriptionTableMap::DATABASE_NAME); |
|
389 | + if (!$dbMap->hasTable(SubscriptionTableMap::TABLE_NAME)) { |
|
390 | + $dbMap->addTableObject(new SubscriptionTableMap()); |
|
391 | + } |
|
392 | + } |
|
393 | + |
|
394 | + /** |
|
395 | + * Performs a DELETE on the database, given a Subscription or Criteria object OR a primary key value. |
|
396 | + * |
|
397 | + * @param mixed $values Criteria or Subscription object or primary key or array of primary keys |
|
398 | + * which is used to create the DELETE statement |
|
399 | + * @param ConnectionInterface $con the connection to use |
|
400 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
401 | + * if supported by native driver or if emulated using Propel. |
|
402 | + * @throws PropelException Any exceptions caught during processing will be |
|
403 | + * rethrown wrapped into a PropelException. |
|
404 | + */ |
|
405 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
406 | + { |
|
407 | + if (null === $con) { |
|
408 | + $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
409 | + } |
|
410 | + |
|
411 | + if ($values instanceof Criteria) { |
|
412 | + // rename for clarity |
|
413 | + $criteria = $values; |
|
414 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\Subscription) { // it's a model object |
|
415 | + // create criteria based on pk values |
|
416 | + $criteria = $values->buildPkeyCriteria(); |
|
417 | + } else { // it's a primary key, or an array of pks |
|
418 | + $criteria = new Criteria(SubscriptionTableMap::DATABASE_NAME); |
|
419 | + $criteria->add(SubscriptionTableMap::COL_ID, (array) $values, Criteria::IN); |
|
420 | + } |
|
421 | + |
|
422 | + $query = SubscriptionQuery::create()->mergeWith($criteria); |
|
423 | + |
|
424 | + if ($values instanceof Criteria) { |
|
425 | + SubscriptionTableMap::clearInstancePool(); |
|
426 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
427 | + foreach ((array) $values as $singleval) { |
|
428 | + SubscriptionTableMap::removeInstanceFromPool($singleval); |
|
429 | + } |
|
430 | + } |
|
431 | + |
|
432 | + return $query->delete($con); |
|
433 | + } |
|
434 | + |
|
435 | + /** |
|
436 | + * Deletes all rows from the subscription table. |
|
437 | + * |
|
438 | + * @param ConnectionInterface $con the connection to use |
|
439 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
440 | + */ |
|
441 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
442 | + { |
|
443 | + return SubscriptionQuery::create()->doDeleteAll($con); |
|
444 | + } |
|
445 | + |
|
446 | + /** |
|
447 | + * Performs an INSERT on the database, given a Subscription or Criteria object. |
|
448 | + * |
|
449 | + * @param mixed $criteria Criteria or Subscription object containing data that is used to create the INSERT statement. |
|
450 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
451 | + * @return mixed The new primary key. |
|
452 | + * @throws PropelException Any exceptions caught during processing will be |
|
453 | + * rethrown wrapped into a PropelException. |
|
454 | + */ |
|
455 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
456 | + { |
|
457 | + if (null === $con) { |
|
458 | + $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
459 | + } |
|
460 | + |
|
461 | + if ($criteria instanceof Criteria) { |
|
462 | + $criteria = clone $criteria; // rename for clarity |
|
463 | + } else { |
|
464 | + $criteria = $criteria->buildCriteria(); // build Criteria from Subscription object |
|
465 | + } |
|
466 | + |
|
467 | + if ($criteria->containsKey(SubscriptionTableMap::COL_ID) && $criteria->keyContainsValue(SubscriptionTableMap::COL_ID) ) { |
|
468 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.SubscriptionTableMap::COL_ID.')'); |
|
469 | + } |
|
470 | + |
|
471 | + |
|
472 | + // Set the correct dbName |
|
473 | + $query = SubscriptionQuery::create()->mergeWith($criteria); |
|
474 | + |
|
475 | + // use transaction because $criteria could contain info |
|
476 | + // for more than one table (I guess, conceivably) |
|
477 | + return $con->transaction(function () use ($con, $query) { |
|
478 | + return $query->doInsert($con); |
|
479 | + }); |
|
480 | + } |
|
481 | 481 | |
482 | 482 | } // SubscriptionTableMap |
483 | 483 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * first dimension keys are the type constants |
128 | 128 | * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
129 | 129 | */ |
130 | - protected static $fieldNames = array ( |
|
131 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'ChannelId', 'SubscriptionId', 'Started', 'Stopped', 'Title', 'Service', ), |
|
132 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'channelId', 'subscriptionId', 'started', 'stopped', 'title', 'service', ), |
|
133 | - self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID, SubscriptionTableMap::COL_INSTANCE_NAME, SubscriptionTableMap::COL_USER_ID, SubscriptionTableMap::COL_CHANNEL_ID, SubscriptionTableMap::COL_SUBSCRIPTION_ID, SubscriptionTableMap::COL_STARTED, SubscriptionTableMap::COL_STOPPED, SubscriptionTableMap::COL_TITLE, SubscriptionTableMap::COL_SERVICE, ), |
|
134 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'channel_id', 'subscription_id', 'started', 'stopped', 'title', 'service', ), |
|
135 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) |
|
130 | + protected static $fieldNames = array( |
|
131 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'ChannelId', 'SubscriptionId', 'Started', 'Stopped', 'Title', 'Service',), |
|
132 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'channelId', 'subscriptionId', 'started', 'stopped', 'title', 'service',), |
|
133 | + self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID, SubscriptionTableMap::COL_INSTANCE_NAME, SubscriptionTableMap::COL_USER_ID, SubscriptionTableMap::COL_CHANNEL_ID, SubscriptionTableMap::COL_SUBSCRIPTION_ID, SubscriptionTableMap::COL_STARTED, SubscriptionTableMap::COL_STOPPED, SubscriptionTableMap::COL_TITLE, SubscriptionTableMap::COL_SERVICE,), |
|
134 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'channel_id', 'subscription_id', 'started', 'stopped', 'title', 'service',), |
|
135 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8,) |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | /** |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | * first dimension keys are the type constants |
142 | 142 | * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
143 | 143 | */ |
144 | - protected static $fieldKeys = array ( |
|
145 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'ChannelId' => 3, 'SubscriptionId' => 4, 'Started' => 5, 'Stopped' => 6, 'Title' => 7, 'Service' => 8, ), |
|
146 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'channelId' => 3, 'subscriptionId' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8, ), |
|
147 | - self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID => 0, SubscriptionTableMap::COL_INSTANCE_NAME => 1, SubscriptionTableMap::COL_USER_ID => 2, SubscriptionTableMap::COL_CHANNEL_ID => 3, SubscriptionTableMap::COL_SUBSCRIPTION_ID => 4, SubscriptionTableMap::COL_STARTED => 5, SubscriptionTableMap::COL_STOPPED => 6, SubscriptionTableMap::COL_TITLE => 7, SubscriptionTableMap::COL_SERVICE => 8, ), |
|
148 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'channel_id' => 3, 'subscription_id' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8, ), |
|
149 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) |
|
144 | + protected static $fieldKeys = array( |
|
145 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'ChannelId' => 3, 'SubscriptionId' => 4, 'Started' => 5, 'Stopped' => 6, 'Title' => 7, 'Service' => 8,), |
|
146 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'channelId' => 3, 'subscriptionId' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8,), |
|
147 | + self::TYPE_COLNAME => array(SubscriptionTableMap::COL_ID => 0, SubscriptionTableMap::COL_INSTANCE_NAME => 1, SubscriptionTableMap::COL_USER_ID => 2, SubscriptionTableMap::COL_CHANNEL_ID => 3, SubscriptionTableMap::COL_SUBSCRIPTION_ID => 4, SubscriptionTableMap::COL_STARTED => 5, SubscriptionTableMap::COL_STOPPED => 6, SubscriptionTableMap::COL_TITLE => 7, SubscriptionTableMap::COL_SERVICE => 8,), |
|
148 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'channel_id' => 3, 'subscription_id' => 4, 'started' => 5, 'stopped' => 6, 'title' => 7, 'service' => 8,), |
|
149 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8,) |
|
150 | 150 | ); |
151 | 151 | |
152 | 152 | /** |
@@ -182,23 +182,23 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function buildRelations() |
184 | 184 | { |
185 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
185 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array( |
|
186 | 186 | 0 => |
187 | - array ( |
|
187 | + array( |
|
188 | 188 | 0 => ':instance_name', |
189 | 189 | 1 => ':name', |
190 | 190 | ), |
191 | 191 | ), null, null, null, false); |
192 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
192 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array( |
|
193 | 193 | 0 => |
194 | - array ( |
|
194 | + array( |
|
195 | 195 | 0 => ':user_id', |
196 | 196 | 1 => ':id', |
197 | 197 | ), |
198 | 198 | ), null, null, null, false); |
199 | - $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::MANY_TO_ONE, array ( |
|
199 | + $this->addRelation('Channel', '\\Jalle19\\StatusManager\\Database\\Channel', RelationMap::MANY_TO_ONE, array( |
|
200 | 200 | 0 => |
201 | - array ( |
|
201 | + array( |
|
202 | 202 | 0 => ':channel_id', |
203 | 203 | 1 => ':id', |
204 | 204 | ), |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | $criteria = $criteria->buildCriteria(); // build Criteria from Subscription object |
465 | 465 | } |
466 | 466 | |
467 | - if ($criteria->containsKey(SubscriptionTableMap::COL_ID) && $criteria->keyContainsValue(SubscriptionTableMap::COL_ID) ) { |
|
468 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.SubscriptionTableMap::COL_ID.')'); |
|
467 | + if ($criteria->containsKey(SubscriptionTableMap::COL_ID) && $criteria->keyContainsValue(SubscriptionTableMap::COL_ID)) { |
|
468 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . SubscriptionTableMap::COL_ID . ')'); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | // use transaction because $criteria could contain info |
476 | 476 | // for more than one table (I guess, conceivably) |
477 | - return $con->transaction(function () use ($con, $query) { |
|
477 | + return $con->transaction(function() use ($con, $query) { |
|
478 | 478 | return $query->doInsert($con); |
479 | 479 | }); |
480 | 480 | } |
@@ -28,408 +28,408 @@ |
||
28 | 28 | */ |
29 | 29 | class UserTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.UserTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'user'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\User'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.User'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 3; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 3; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'user.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'user.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the name field |
|
86 | - */ |
|
87 | - const COL_NAME = 'user.name'; |
|
88 | - |
|
89 | - /** |
|
90 | - * The default string format for model objects of the related table |
|
91 | - */ |
|
92 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | - |
|
94 | - /** |
|
95 | - * holds an array of fieldnames |
|
96 | - * |
|
97 | - * first dimension keys are the type constants |
|
98 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | - */ |
|
100 | - protected static $fieldNames = array ( |
|
101 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | - self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_INSTANCE_NAME, UserTableMap::COL_NAME, ), |
|
104 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | - ); |
|
107 | - |
|
108 | - /** |
|
109 | - * holds an array of keys for quick access to the fieldnames array |
|
110 | - * |
|
111 | - * first dimension keys are the type constants |
|
112 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | - */ |
|
114 | - protected static $fieldKeys = array ( |
|
115 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | - self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_INSTANCE_NAME => 1, UserTableMap::COL_NAME => 2, ), |
|
118 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | - ); |
|
121 | - |
|
122 | - /** |
|
123 | - * Initialize the table attributes and columns |
|
124 | - * Relations are not initialized by this method since they are lazy loaded |
|
125 | - * |
|
126 | - * @return void |
|
127 | - * @throws PropelException |
|
128 | - */ |
|
129 | - public function initialize() |
|
130 | - { |
|
131 | - // attributes |
|
132 | - $this->setName('user'); |
|
133 | - $this->setPhpName('User'); |
|
134 | - $this->setIdentifierQuoting(false); |
|
135 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\User'); |
|
136 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | - $this->setUseIdGenerator(true); |
|
138 | - // columns |
|
139 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | - $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | - } // initialize() |
|
143 | - |
|
144 | - /** |
|
145 | - * Build the RelationMap objects for this table relationships |
|
146 | - */ |
|
147 | - public function buildRelations() |
|
148 | - { |
|
149 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.UserTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'user'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\User'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.User'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 3; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 3; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'user.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'user.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the name field |
|
86 | + */ |
|
87 | + const COL_NAME = 'user.name'; |
|
88 | + |
|
89 | + /** |
|
90 | + * The default string format for model objects of the related table |
|
91 | + */ |
|
92 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | + |
|
94 | + /** |
|
95 | + * holds an array of fieldnames |
|
96 | + * |
|
97 | + * first dimension keys are the type constants |
|
98 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | + */ |
|
100 | + protected static $fieldNames = array ( |
|
101 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | + self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_INSTANCE_NAME, UserTableMap::COL_NAME, ), |
|
104 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | + ); |
|
107 | + |
|
108 | + /** |
|
109 | + * holds an array of keys for quick access to the fieldnames array |
|
110 | + * |
|
111 | + * first dimension keys are the type constants |
|
112 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | + */ |
|
114 | + protected static $fieldKeys = array ( |
|
115 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | + self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_INSTANCE_NAME => 1, UserTableMap::COL_NAME => 2, ), |
|
118 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | + ); |
|
121 | + |
|
122 | + /** |
|
123 | + * Initialize the table attributes and columns |
|
124 | + * Relations are not initialized by this method since they are lazy loaded |
|
125 | + * |
|
126 | + * @return void |
|
127 | + * @throws PropelException |
|
128 | + */ |
|
129 | + public function initialize() |
|
130 | + { |
|
131 | + // attributes |
|
132 | + $this->setName('user'); |
|
133 | + $this->setPhpName('User'); |
|
134 | + $this->setIdentifierQuoting(false); |
|
135 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\User'); |
|
136 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | + $this->setUseIdGenerator(true); |
|
138 | + // columns |
|
139 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | + $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | + } // initialize() |
|
143 | + |
|
144 | + /** |
|
145 | + * Build the RelationMap objects for this table relationships |
|
146 | + */ |
|
147 | + public function buildRelations() |
|
148 | + { |
|
149 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
150 | 150 | 0 => |
151 | 151 | array ( |
152 | - 0 => ':instance_name', |
|
153 | - 1 => ':name', |
|
152 | + 0 => ':instance_name', |
|
153 | + 1 => ':name', |
|
154 | 154 | ), |
155 | 155 | ), null, null, null, false); |
156 | - $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
156 | + $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
157 | 157 | 0 => |
158 | 158 | array ( |
159 | - 0 => ':user_id', |
|
160 | - 1 => ':id', |
|
159 | + 0 => ':user_id', |
|
160 | + 1 => ':id', |
|
161 | 161 | ), |
162 | 162 | ), null, null, 'Connections', false); |
163 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
163 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
164 | 164 | 0 => |
165 | 165 | array ( |
166 | - 0 => ':user_id', |
|
167 | - 1 => ':id', |
|
166 | + 0 => ':user_id', |
|
167 | + 1 => ':id', |
|
168 | 168 | ), |
169 | 169 | ), null, null, 'Subscriptions', false); |
170 | - } // buildRelations() |
|
171 | - |
|
172 | - /** |
|
173 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
174 | - * |
|
175 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
176 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
177 | - * |
|
178 | - * @param array $row resultset row. |
|
179 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
180 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
181 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
182 | - * |
|
183 | - * @return string The primary key hash of the row |
|
184 | - */ |
|
185 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
186 | - { |
|
187 | - // If the PK cannot be derived from the row, return NULL. |
|
188 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
189 | - return null; |
|
190 | - } |
|
191 | - |
|
192 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Retrieves the primary key from the DB resultset row |
|
197 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
198 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
199 | - * |
|
200 | - * @param array $row resultset row. |
|
201 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
202 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
203 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
204 | - * |
|
205 | - * @return mixed The primary key of the row |
|
206 | - */ |
|
207 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
208 | - { |
|
209 | - return (int) $row[ |
|
210 | - $indexType == TableMap::TYPE_NUM |
|
211 | - ? 0 + $offset |
|
212 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
213 | - ]; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * The class that the tableMap will make instances of. |
|
218 | - * |
|
219 | - * If $withPrefix is true, the returned path |
|
220 | - * uses a dot-path notation which is translated into a path |
|
221 | - * relative to a location on the PHP include_path. |
|
222 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
223 | - * |
|
224 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
225 | - * @return string path.to.ClassName |
|
226 | - */ |
|
227 | - public static function getOMClass($withPrefix = true) |
|
228 | - { |
|
229 | - return $withPrefix ? UserTableMap::CLASS_DEFAULT : UserTableMap::OM_CLASS; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Populates an object of the default type or an object that inherit from the default. |
|
234 | - * |
|
235 | - * @param array $row row returned by DataFetcher->fetch(). |
|
236 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
237 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
170 | + } // buildRelations() |
|
171 | + |
|
172 | + /** |
|
173 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
174 | + * |
|
175 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
176 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
177 | + * |
|
178 | + * @param array $row resultset row. |
|
179 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
180 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
181 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
182 | + * |
|
183 | + * @return string The primary key hash of the row |
|
184 | + */ |
|
185 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
186 | + { |
|
187 | + // If the PK cannot be derived from the row, return NULL. |
|
188 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
189 | + return null; |
|
190 | + } |
|
191 | + |
|
192 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Retrieves the primary key from the DB resultset row |
|
197 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
198 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
199 | + * |
|
200 | + * @param array $row resultset row. |
|
201 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
202 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
203 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
204 | + * |
|
205 | + * @return mixed The primary key of the row |
|
206 | + */ |
|
207 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
208 | + { |
|
209 | + return (int) $row[ |
|
210 | + $indexType == TableMap::TYPE_NUM |
|
211 | + ? 0 + $offset |
|
212 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
213 | + ]; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * The class that the tableMap will make instances of. |
|
218 | + * |
|
219 | + * If $withPrefix is true, the returned path |
|
220 | + * uses a dot-path notation which is translated into a path |
|
221 | + * relative to a location on the PHP include_path. |
|
222 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
223 | + * |
|
224 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
225 | + * @return string path.to.ClassName |
|
226 | + */ |
|
227 | + public static function getOMClass($withPrefix = true) |
|
228 | + { |
|
229 | + return $withPrefix ? UserTableMap::CLASS_DEFAULT : UserTableMap::OM_CLASS; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Populates an object of the default type or an object that inherit from the default. |
|
234 | + * |
|
235 | + * @param array $row row returned by DataFetcher->fetch(). |
|
236 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
237 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
238 | 238 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
239 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
240 | - * |
|
241 | - * @throws PropelException Any exceptions caught during processing will be |
|
242 | - * rethrown wrapped into a PropelException. |
|
243 | - * @return array (User object, last column rank) |
|
244 | - */ |
|
245 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
246 | - { |
|
247 | - $key = UserTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
248 | - if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
249 | - // We no longer rehydrate the object, since this can cause data loss. |
|
250 | - // See http://www.propelorm.org/ticket/509 |
|
251 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
252 | - $col = $offset + UserTableMap::NUM_HYDRATE_COLUMNS; |
|
253 | - } else { |
|
254 | - $cls = UserTableMap::OM_CLASS; |
|
255 | - /** @var User $obj */ |
|
256 | - $obj = new $cls(); |
|
257 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
258 | - UserTableMap::addInstanceToPool($obj, $key); |
|
259 | - } |
|
260 | - |
|
261 | - return array($obj, $col); |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * The returned array will contain objects of the default type or |
|
266 | - * objects that inherit from the default. |
|
267 | - * |
|
268 | - * @param DataFetcherInterface $dataFetcher |
|
269 | - * @return array |
|
270 | - * @throws PropelException Any exceptions caught during processing will be |
|
271 | - * rethrown wrapped into a PropelException. |
|
272 | - */ |
|
273 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
274 | - { |
|
275 | - $results = array(); |
|
276 | - |
|
277 | - // set the class once to avoid overhead in the loop |
|
278 | - $cls = static::getOMClass(false); |
|
279 | - // populate the object(s) |
|
280 | - while ($row = $dataFetcher->fetch()) { |
|
281 | - $key = UserTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
282 | - if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
283 | - // We no longer rehydrate the object, since this can cause data loss. |
|
284 | - // See http://www.propelorm.org/ticket/509 |
|
285 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
286 | - $results[] = $obj; |
|
287 | - } else { |
|
288 | - /** @var User $obj */ |
|
289 | - $obj = new $cls(); |
|
290 | - $obj->hydrate($row); |
|
291 | - $results[] = $obj; |
|
292 | - UserTableMap::addInstanceToPool($obj, $key); |
|
293 | - } // if key exists |
|
294 | - } |
|
295 | - |
|
296 | - return $results; |
|
297 | - } |
|
298 | - /** |
|
299 | - * Add all the columns needed to create a new object. |
|
300 | - * |
|
301 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
302 | - * XML schema will not be added to the select list and only loaded |
|
303 | - * on demand. |
|
304 | - * |
|
305 | - * @param Criteria $criteria object containing the columns to add. |
|
306 | - * @param string $alias optional table alias |
|
307 | - * @throws PropelException Any exceptions caught during processing will be |
|
308 | - * rethrown wrapped into a PropelException. |
|
309 | - */ |
|
310 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
311 | - { |
|
312 | - if (null === $alias) { |
|
313 | - $criteria->addSelectColumn(UserTableMap::COL_ID); |
|
314 | - $criteria->addSelectColumn(UserTableMap::COL_INSTANCE_NAME); |
|
315 | - $criteria->addSelectColumn(UserTableMap::COL_NAME); |
|
316 | - } else { |
|
317 | - $criteria->addSelectColumn($alias . '.id'); |
|
318 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
319 | - $criteria->addSelectColumn($alias . '.name'); |
|
320 | - } |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Returns the TableMap related to this object. |
|
325 | - * This method is not needed for general use but a specific application could have a need. |
|
326 | - * @return TableMap |
|
327 | - * @throws PropelException Any exceptions caught during processing will be |
|
328 | - * rethrown wrapped into a PropelException. |
|
329 | - */ |
|
330 | - public static function getTableMap() |
|
331 | - { |
|
332 | - return Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME)->getTable(UserTableMap::TABLE_NAME); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * Add a TableMap instance to the database for this tableMap class. |
|
337 | - */ |
|
338 | - public static function buildTableMap() |
|
339 | - { |
|
340 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME); |
|
341 | - if (!$dbMap->hasTable(UserTableMap::TABLE_NAME)) { |
|
342 | - $dbMap->addTableObject(new UserTableMap()); |
|
343 | - } |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Performs a DELETE on the database, given a User or Criteria object OR a primary key value. |
|
348 | - * |
|
349 | - * @param mixed $values Criteria or User object or primary key or array of primary keys |
|
350 | - * which is used to create the DELETE statement |
|
351 | - * @param ConnectionInterface $con the connection to use |
|
352 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
353 | - * if supported by native driver or if emulated using Propel. |
|
354 | - * @throws PropelException Any exceptions caught during processing will be |
|
355 | - * rethrown wrapped into a PropelException. |
|
356 | - */ |
|
357 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
358 | - { |
|
359 | - if (null === $con) { |
|
360 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
361 | - } |
|
362 | - |
|
363 | - if ($values instanceof Criteria) { |
|
364 | - // rename for clarity |
|
365 | - $criteria = $values; |
|
366 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\User) { // it's a model object |
|
367 | - // create criteria based on pk values |
|
368 | - $criteria = $values->buildPkeyCriteria(); |
|
369 | - } else { // it's a primary key, or an array of pks |
|
370 | - $criteria = new Criteria(UserTableMap::DATABASE_NAME); |
|
371 | - $criteria->add(UserTableMap::COL_ID, (array) $values, Criteria::IN); |
|
372 | - } |
|
373 | - |
|
374 | - $query = UserQuery::create()->mergeWith($criteria); |
|
375 | - |
|
376 | - if ($values instanceof Criteria) { |
|
377 | - UserTableMap::clearInstancePool(); |
|
378 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
379 | - foreach ((array) $values as $singleval) { |
|
380 | - UserTableMap::removeInstanceFromPool($singleval); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - return $query->delete($con); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Deletes all rows from the user table. |
|
389 | - * |
|
390 | - * @param ConnectionInterface $con the connection to use |
|
391 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
392 | - */ |
|
393 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
394 | - { |
|
395 | - return UserQuery::create()->doDeleteAll($con); |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * Performs an INSERT on the database, given a User or Criteria object. |
|
400 | - * |
|
401 | - * @param mixed $criteria Criteria or User object containing data that is used to create the INSERT statement. |
|
402 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
403 | - * @return mixed The new primary key. |
|
404 | - * @throws PropelException Any exceptions caught during processing will be |
|
405 | - * rethrown wrapped into a PropelException. |
|
406 | - */ |
|
407 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
408 | - { |
|
409 | - if (null === $con) { |
|
410 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
411 | - } |
|
412 | - |
|
413 | - if ($criteria instanceof Criteria) { |
|
414 | - $criteria = clone $criteria; // rename for clarity |
|
415 | - } else { |
|
416 | - $criteria = $criteria->buildCriteria(); // build Criteria from User object |
|
417 | - } |
|
418 | - |
|
419 | - if ($criteria->containsKey(UserTableMap::COL_ID) && $criteria->keyContainsValue(UserTableMap::COL_ID) ) { |
|
420 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.UserTableMap::COL_ID.')'); |
|
421 | - } |
|
422 | - |
|
423 | - |
|
424 | - // Set the correct dbName |
|
425 | - $query = UserQuery::create()->mergeWith($criteria); |
|
426 | - |
|
427 | - // use transaction because $criteria could contain info |
|
428 | - // for more than one table (I guess, conceivably) |
|
429 | - return $con->transaction(function () use ($con, $query) { |
|
430 | - return $query->doInsert($con); |
|
431 | - }); |
|
432 | - } |
|
239 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
240 | + * |
|
241 | + * @throws PropelException Any exceptions caught during processing will be |
|
242 | + * rethrown wrapped into a PropelException. |
|
243 | + * @return array (User object, last column rank) |
|
244 | + */ |
|
245 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
246 | + { |
|
247 | + $key = UserTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
248 | + if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
249 | + // We no longer rehydrate the object, since this can cause data loss. |
|
250 | + // See http://www.propelorm.org/ticket/509 |
|
251 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
252 | + $col = $offset + UserTableMap::NUM_HYDRATE_COLUMNS; |
|
253 | + } else { |
|
254 | + $cls = UserTableMap::OM_CLASS; |
|
255 | + /** @var User $obj */ |
|
256 | + $obj = new $cls(); |
|
257 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
258 | + UserTableMap::addInstanceToPool($obj, $key); |
|
259 | + } |
|
260 | + |
|
261 | + return array($obj, $col); |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * The returned array will contain objects of the default type or |
|
266 | + * objects that inherit from the default. |
|
267 | + * |
|
268 | + * @param DataFetcherInterface $dataFetcher |
|
269 | + * @return array |
|
270 | + * @throws PropelException Any exceptions caught during processing will be |
|
271 | + * rethrown wrapped into a PropelException. |
|
272 | + */ |
|
273 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
274 | + { |
|
275 | + $results = array(); |
|
276 | + |
|
277 | + // set the class once to avoid overhead in the loop |
|
278 | + $cls = static::getOMClass(false); |
|
279 | + // populate the object(s) |
|
280 | + while ($row = $dataFetcher->fetch()) { |
|
281 | + $key = UserTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
282 | + if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
283 | + // We no longer rehydrate the object, since this can cause data loss. |
|
284 | + // See http://www.propelorm.org/ticket/509 |
|
285 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
286 | + $results[] = $obj; |
|
287 | + } else { |
|
288 | + /** @var User $obj */ |
|
289 | + $obj = new $cls(); |
|
290 | + $obj->hydrate($row); |
|
291 | + $results[] = $obj; |
|
292 | + UserTableMap::addInstanceToPool($obj, $key); |
|
293 | + } // if key exists |
|
294 | + } |
|
295 | + |
|
296 | + return $results; |
|
297 | + } |
|
298 | + /** |
|
299 | + * Add all the columns needed to create a new object. |
|
300 | + * |
|
301 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
302 | + * XML schema will not be added to the select list and only loaded |
|
303 | + * on demand. |
|
304 | + * |
|
305 | + * @param Criteria $criteria object containing the columns to add. |
|
306 | + * @param string $alias optional table alias |
|
307 | + * @throws PropelException Any exceptions caught during processing will be |
|
308 | + * rethrown wrapped into a PropelException. |
|
309 | + */ |
|
310 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
311 | + { |
|
312 | + if (null === $alias) { |
|
313 | + $criteria->addSelectColumn(UserTableMap::COL_ID); |
|
314 | + $criteria->addSelectColumn(UserTableMap::COL_INSTANCE_NAME); |
|
315 | + $criteria->addSelectColumn(UserTableMap::COL_NAME); |
|
316 | + } else { |
|
317 | + $criteria->addSelectColumn($alias . '.id'); |
|
318 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
319 | + $criteria->addSelectColumn($alias . '.name'); |
|
320 | + } |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * Returns the TableMap related to this object. |
|
325 | + * This method is not needed for general use but a specific application could have a need. |
|
326 | + * @return TableMap |
|
327 | + * @throws PropelException Any exceptions caught during processing will be |
|
328 | + * rethrown wrapped into a PropelException. |
|
329 | + */ |
|
330 | + public static function getTableMap() |
|
331 | + { |
|
332 | + return Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME)->getTable(UserTableMap::TABLE_NAME); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * Add a TableMap instance to the database for this tableMap class. |
|
337 | + */ |
|
338 | + public static function buildTableMap() |
|
339 | + { |
|
340 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME); |
|
341 | + if (!$dbMap->hasTable(UserTableMap::TABLE_NAME)) { |
|
342 | + $dbMap->addTableObject(new UserTableMap()); |
|
343 | + } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Performs a DELETE on the database, given a User or Criteria object OR a primary key value. |
|
348 | + * |
|
349 | + * @param mixed $values Criteria or User object or primary key or array of primary keys |
|
350 | + * which is used to create the DELETE statement |
|
351 | + * @param ConnectionInterface $con the connection to use |
|
352 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
353 | + * if supported by native driver or if emulated using Propel. |
|
354 | + * @throws PropelException Any exceptions caught during processing will be |
|
355 | + * rethrown wrapped into a PropelException. |
|
356 | + */ |
|
357 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
358 | + { |
|
359 | + if (null === $con) { |
|
360 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
361 | + } |
|
362 | + |
|
363 | + if ($values instanceof Criteria) { |
|
364 | + // rename for clarity |
|
365 | + $criteria = $values; |
|
366 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\User) { // it's a model object |
|
367 | + // create criteria based on pk values |
|
368 | + $criteria = $values->buildPkeyCriteria(); |
|
369 | + } else { // it's a primary key, or an array of pks |
|
370 | + $criteria = new Criteria(UserTableMap::DATABASE_NAME); |
|
371 | + $criteria->add(UserTableMap::COL_ID, (array) $values, Criteria::IN); |
|
372 | + } |
|
373 | + |
|
374 | + $query = UserQuery::create()->mergeWith($criteria); |
|
375 | + |
|
376 | + if ($values instanceof Criteria) { |
|
377 | + UserTableMap::clearInstancePool(); |
|
378 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
379 | + foreach ((array) $values as $singleval) { |
|
380 | + UserTableMap::removeInstanceFromPool($singleval); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + return $query->delete($con); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Deletes all rows from the user table. |
|
389 | + * |
|
390 | + * @param ConnectionInterface $con the connection to use |
|
391 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
392 | + */ |
|
393 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
394 | + { |
|
395 | + return UserQuery::create()->doDeleteAll($con); |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * Performs an INSERT on the database, given a User or Criteria object. |
|
400 | + * |
|
401 | + * @param mixed $criteria Criteria or User object containing data that is used to create the INSERT statement. |
|
402 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
403 | + * @return mixed The new primary key. |
|
404 | + * @throws PropelException Any exceptions caught during processing will be |
|
405 | + * rethrown wrapped into a PropelException. |
|
406 | + */ |
|
407 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
408 | + { |
|
409 | + if (null === $con) { |
|
410 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
411 | + } |
|
412 | + |
|
413 | + if ($criteria instanceof Criteria) { |
|
414 | + $criteria = clone $criteria; // rename for clarity |
|
415 | + } else { |
|
416 | + $criteria = $criteria->buildCriteria(); // build Criteria from User object |
|
417 | + } |
|
418 | + |
|
419 | + if ($criteria->containsKey(UserTableMap::COL_ID) && $criteria->keyContainsValue(UserTableMap::COL_ID) ) { |
|
420 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.UserTableMap::COL_ID.')'); |
|
421 | + } |
|
422 | + |
|
423 | + |
|
424 | + // Set the correct dbName |
|
425 | + $query = UserQuery::create()->mergeWith($criteria); |
|
426 | + |
|
427 | + // use transaction because $criteria could contain info |
|
428 | + // for more than one table (I guess, conceivably) |
|
429 | + return $con->transaction(function () use ($con, $query) { |
|
430 | + return $query->doInsert($con); |
|
431 | + }); |
|
432 | + } |
|
433 | 433 | |
434 | 434 | } // UserTableMap |
435 | 435 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * first dimension keys are the type constants |
98 | 98 | * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
99 | 99 | */ |
100 | - protected static $fieldNames = array ( |
|
101 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | - self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_INSTANCE_NAME, UserTableMap::COL_NAME, ), |
|
104 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
100 | + protected static $fieldNames = array( |
|
101 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name',), |
|
102 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'name',), |
|
103 | + self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_INSTANCE_NAME, UserTableMap::COL_NAME,), |
|
104 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'name',), |
|
105 | + self::TYPE_NUM => array(0, 1, 2,) |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | /** |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | * first dimension keys are the type constants |
112 | 112 | * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
113 | 113 | */ |
114 | - protected static $fieldKeys = array ( |
|
115 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | - self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_INSTANCE_NAME => 1, UserTableMap::COL_NAME => 2, ), |
|
118 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
114 | + protected static $fieldKeys = array( |
|
115 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2,), |
|
116 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2,), |
|
117 | + self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_INSTANCE_NAME => 1, UserTableMap::COL_NAME => 2,), |
|
118 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2,), |
|
119 | + self::TYPE_NUM => array(0, 1, 2,) |
|
120 | 120 | ); |
121 | 121 | |
122 | 122 | /** |
@@ -146,23 +146,23 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function buildRelations() |
148 | 148 | { |
149 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
149 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array( |
|
150 | 150 | 0 => |
151 | - array ( |
|
151 | + array( |
|
152 | 152 | 0 => ':instance_name', |
153 | 153 | 1 => ':name', |
154 | 154 | ), |
155 | 155 | ), null, null, null, false); |
156 | - $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
156 | + $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array( |
|
157 | 157 | 0 => |
158 | - array ( |
|
158 | + array( |
|
159 | 159 | 0 => ':user_id', |
160 | 160 | 1 => ':id', |
161 | 161 | ), |
162 | 162 | ), null, null, 'Connections', false); |
163 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
163 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array( |
|
164 | 164 | 0 => |
165 | - array ( |
|
165 | + array( |
|
166 | 166 | 0 => ':user_id', |
167 | 167 | 1 => ':id', |
168 | 168 | ), |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | $criteria = $criteria->buildCriteria(); // build Criteria from User object |
417 | 417 | } |
418 | 418 | |
419 | - if ($criteria->containsKey(UserTableMap::COL_ID) && $criteria->keyContainsValue(UserTableMap::COL_ID) ) { |
|
420 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.UserTableMap::COL_ID.')'); |
|
419 | + if ($criteria->containsKey(UserTableMap::COL_ID) && $criteria->keyContainsValue(UserTableMap::COL_ID)) { |
|
420 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | // use transaction because $criteria could contain info |
428 | 428 | // for more than one table (I guess, conceivably) |
429 | - return $con->transaction(function () use ($con, $query) { |
|
429 | + return $con->transaction(function() use ($con, $query) { |
|
430 | 430 | return $query->doInsert($con); |
431 | 431 | }); |
432 | 432 | } |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | $this->onUserSeen($instanceName, $connectionStatus->user); |
92 | 92 | |
93 | 93 | $user = UserQuery::create()->filterByInstanceName($instanceName)->filterByName($connectionStatus->user) |
94 | - ->findOne(); |
|
94 | + ->findOne(); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $connection = new Connection(); |
98 | 98 | $connection->setInstanceName($instanceName)->setPeer($connectionStatus->peer) |
99 | - ->setUser($user) |
|
100 | - ->setStarted($connectionStatus->started)->setType($connectionStatus->type)->save(); |
|
99 | + ->setUser($user) |
|
100 | + ->setStarted($connectionStatus->started)->setType($connectionStatus->type)->save(); |
|
101 | 101 | |
102 | 102 | $this->_logger->info('Stored new connection (instance: {instanceName}, peer: {peer})', [ |
103 | 103 | 'instanceName' => $instanceName, |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | |
186 | 186 | $subscription = new Subscription(); |
187 | 187 | $subscription->setInstance($instance)->setUser($user)->setChannel($channel) |
188 | - ->setSubscriptionId($status->id)->setStarted($status->start)->setTitle($status->title) |
|
189 | - ->setService($status->service); |
|
188 | + ->setSubscriptionId($status->id)->setStarted($status->start)->setTitle($status->title) |
|
189 | + ->setService($status->service); |
|
190 | 190 | $subscription->save(); |
191 | 191 | |
192 | 192 | $this->_logger->info('Stored new subscription (instance: {instanceName}, user: {userName}, channel: {channelName})', |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | |
211 | 211 | // Find the latest matching subscription |
212 | 212 | $subscription = SubscriptionQuery::create()->filterByInstanceName($instanceName) |
213 | - ->filterBySubscriptionId($stateChange->getSubscriptionId()) |
|
214 | - ->addDescendingOrderByColumn('started')->findOne(); |
|
213 | + ->filterBySubscriptionId($stateChange->getSubscriptionId()) |
|
214 | + ->addDescendingOrderByColumn('started')->findOne(); |
|
215 | 215 | |
216 | 216 | if ($subscription === null) |
217 | 217 | { |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | private function hasConnection($instanceName, ConnectionStatus $connectionStatus) |
260 | 260 | { |
261 | 261 | return ConnectionQuery::create()->filterByInstanceName($instanceName)->filterByPeer($connectionStatus->peer) |
262 | - ->filterByStarted($connectionStatus->started)->findOne() !== null; |
|
262 | + ->filterByStarted($connectionStatus->started)->findOne() !== null; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | private function hasChannel($instanceName, $channelName) |
285 | 285 | { |
286 | 286 | return ChannelQuery::create()->filterByInstanceName($instanceName)->filterByName($channelName) |
287 | - ->findOne() !== null; |
|
287 | + ->findOne() !== null; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | $userId = $user !== null ? $user->getId() : null; |
308 | 308 | |
309 | 309 | return SubscriptionQuery::create()->filterByInstance($instance)->filterByUserId($userId) |
310 | - ->filterByChannel($channel) |
|
311 | - ->filterBySubscriptionId($subscription->id)->filterByStarted($subscription->start) |
|
312 | - ->findOne() !== null; |
|
310 | + ->filterByChannel($channel) |
|
311 | + ->filterBySubscriptionId($subscription->id)->filterByStarted($subscription->start) |
|
312 | + ->findOne() !== null; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function onInstanceSeen(Tvheadend $instance) |
52 | 52 | { |
53 | - if ($this->hasInstance($instance)) |
|
54 | - return; |
|
53 | + if ($this->hasInstance($instance)) { |
|
54 | + return; |
|
55 | + } |
|
55 | 56 | |
56 | 57 | $instanceModel = new Database\Instance(); |
57 | 58 | $instanceModel->setPrimaryKey($instance->getHostname()); |
@@ -80,8 +81,9 @@ discard block |
||
80 | 81 | */ |
81 | 82 | public function onConnectionSeen($instanceName, ConnectionStatus $connectionStatus) |
82 | 83 | { |
83 | - if ($this->hasConnection($instanceName, $connectionStatus)) |
|
84 | - return; |
|
84 | + if ($this->hasConnection($instanceName, $connectionStatus)) { |
|
85 | + return; |
|
86 | + } |
|
85 | 87 | |
86 | 88 | $user = null; |
87 | 89 | |
@@ -114,8 +116,9 @@ discard block |
||
114 | 116 | */ |
115 | 117 | public function onUserSeen($instanceName, $userName) |
116 | 118 | { |
117 | - if ($this->hasUser($instanceName, $userName)) |
|
118 | - return; |
|
119 | + if ($this->hasUser($instanceName, $userName)) { |
|
120 | + return; |
|
121 | + } |
|
119 | 122 | |
120 | 123 | $user = new User(); |
121 | 124 | $user->setInstanceName($instanceName)->setName($userName); |
@@ -136,8 +139,9 @@ discard block |
||
136 | 139 | */ |
137 | 140 | public function onChannelSeen($instanceName, $channelName) |
138 | 141 | { |
139 | - if ($this->hasChannel($instanceName, $channelName)) |
|
140 | - return; |
|
142 | + if ($this->hasChannel($instanceName, $channelName)) { |
|
143 | + return; |
|
144 | + } |
|
141 | 145 | |
142 | 146 | $channel = new Channel(); |
143 | 147 | $channel->setInstanceName($instanceName)->setName($channelName); |
@@ -159,8 +163,9 @@ discard block |
||
159 | 163 | public function onSubscriptionSeen($instanceName, SubscriptionStatus $status) |
160 | 164 | { |
161 | 165 | // Ignore EPG grabber subscriptions |
162 | - if ($status->getType() === SubscriptionStatus::TYPE_EPGGRAB) |
|
163 | - return; |
|
166 | + if ($status->getType() === SubscriptionStatus::TYPE_EPGGRAB) { |
|
167 | + return; |
|
168 | + } |
|
164 | 169 | |
165 | 170 | // Determine the username to store for the subscription |
166 | 171 | $username = $status->username; |
@@ -180,8 +185,9 @@ discard block |
||
180 | 185 | $this->onChannelSeen($instanceName, $status->channel); |
181 | 186 | $channel = ChannelQuery::create()->filterByInstance($instance)->filterByName($status->channel)->findOne(); |
182 | 187 | |
183 | - if ($this->hasSubscription($instance, $user, $channel, $status)) |
|
184 | - return; |
|
188 | + if ($this->hasSubscription($instance, $user, $channel, $status)) { |
|
189 | + return; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | $subscription = new Subscription(); |
187 | 193 | $subscription->setInstance($instance)->setUser($user)->setChannel($channel) |
@@ -205,8 +211,9 @@ discard block |
||
205 | 211 | public function onSubscriptionStateChange($instanceName, StateChange $stateChange) |
206 | 212 | { |
207 | 213 | // We only need to persist subscription stops |
208 | - if ($stateChange->getState() === StateChange::STATE_SUBSCRIPTION_STARTED) |
|
209 | - return; |
|
214 | + if ($stateChange->getState() === StateChange::STATE_SUBSCRIPTION_STARTED) { |
|
215 | + return; |
|
216 | + } |
|
210 | 217 | |
211 | 218 | // Find the latest matching subscription |
212 | 219 | $subscription = SubscriptionQuery::create()->filterByInstanceName($instanceName) |
@@ -251,7 +251,7 @@ |
||
251 | 251 | |
252 | 252 | |
253 | 253 | /** |
254 | - * @param $instanceName |
|
254 | + * @param string $instanceName |
|
255 | 255 | * @param ConnectionStatus $connectionStatus |
256 | 256 | * |
257 | 257 | * @return bool whether the connection exists in the database |
@@ -70,8 +70,9 @@ discard block |
||
70 | 70 | $this->_instances = new \SplObjectStorage(); |
71 | 71 | |
72 | 72 | // Attach a state to each instance |
73 | - foreach ($this->_configuration->getInstances() as $instance) |
|
74 | - $this->_instances->attach($instance, new InstanceState()); |
|
73 | + foreach ($this->_configuration->getInstances() as $instance) { |
|
74 | + $this->_instances->attach($instance, new InstanceState()); |
|
75 | + } |
|
75 | 76 | |
76 | 77 | // Start the persistence manager |
77 | 78 | $this->_persistenceManager = new PersistenceManager($logger); |
@@ -147,16 +148,19 @@ discard block |
||
147 | 148 | ]); |
148 | 149 | |
149 | 150 | // Persist connections |
150 | - foreach ($instanceStatus->getConnections() as $connection) |
|
151 | - $this->_persistenceManager->onConnectionSeen($instanceName, $connection); |
|
151 | + foreach ($instanceStatus->getConnections() as $connection) { |
|
152 | + $this->_persistenceManager->onConnectionSeen($instanceName, $connection); |
|
153 | + } |
|
152 | 154 | |
153 | 155 | // Persist running subscriptions |
154 | - foreach ($instanceStatus->getSubscriptions() as $subscription) |
|
155 | - $this->_persistenceManager->onSubscriptionSeen($instanceName, $subscription); |
|
156 | + foreach ($instanceStatus->getSubscriptions() as $subscription) { |
|
157 | + $this->_persistenceManager->onSubscriptionSeen($instanceName, $subscription); |
|
158 | + } |
|
156 | 159 | |
157 | 160 | // Handle subscription state changes |
158 | - foreach ($instanceStatus->getSubscriptionStateChanges() as $subscriptionStateChange) |
|
159 | - $this->_persistenceManager->onSubscriptionStateChange($instanceName, $subscriptionStateChange); |
|
161 | + foreach ($instanceStatus->getSubscriptionStateChanges() as $subscriptionStateChange) { |
|
162 | + $this->_persistenceManager->onSubscriptionStateChange($instanceName, $subscriptionStateChange); |
|
163 | + } |
|
160 | 164 | } |
161 | 165 | |
162 | 166 | // Broadcast the status messages to all connected clients |
@@ -204,8 +208,7 @@ discard block |
||
204 | 208 | |
205 | 209 | $instanceState->setReachability(InstanceState::REACHABLE); |
206 | 210 | } |
207 | - } |
|
208 | - catch (\Exception $e) |
|
211 | + } catch (\Exception $e) |
|
209 | 212 | { |
210 | 213 | // Mark the instance as unreachable |
211 | 214 | $message = 'Instance {instanceName} not reachable, will wait for {cycles} cycles before retrying. |
@@ -219,8 +222,7 @@ discard block |
||
219 | 222 | |
220 | 223 | $instanceState->setReachability(InstanceState::UNREACHABLE); |
221 | 224 | } |
222 | - } |
|
223 | - else |
|
225 | + } else |
|
224 | 226 | { |
225 | 227 | // Wait for some cycles and then mark unreachable instances as maybe reachable |
226 | 228 | if ($instanceState->getRetryCount() === self::UNREACHABLE_CYCLES_UNTIL_RETRY - 1) |
@@ -231,9 +233,9 @@ discard block |
||
231 | 233 | $this->_logger->info('Retrying instance {instanceName} during next cycle', [ |
232 | 234 | 'instanceName' => $instanceName, |
233 | 235 | ]); |
236 | + } else { |
|
237 | + $instanceState->incrementRetryCount(); |
|
234 | 238 | } |
235 | - else |
|
236 | - $instanceState->incrementRetryCount(); |
|
237 | 239 | } |
238 | 240 | } |
239 | 241 |