Changeset 7 for trunk/Packages/Common/Form/Form.php
- Timestamp:
- Apr 14, 2020, 11:13:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Form/Form.php
r1 r7 44 44 { 45 45 $Result = '<table class="BasicTable">'; 46 if (array_key_exists('Header', $Table))46 if (array_key_exists('Header', $Table)) 47 47 { 48 48 $Result .= '<tr>'; 49 foreach ($Table['Header'] as $Item)49 foreach ($Table['Header'] as $Item) 50 50 $Result .= '<th>'.$Item.'</th>'; 51 51 $Result .= '</tr>'; 52 52 } 53 foreach ($Table['Rows'] as $Row)53 foreach ($Table['Rows'] as $Row) 54 54 { 55 55 $Result .= '<tr>'; 56 foreach ($Row as $Index => $Item)57 { 58 if ($Index == 0) $Class = ' class="Header"'; else $Class = '';56 foreach ($Row as $Index => $Item) 57 { 58 if ($Index == 0) $Class = ' class="Header"'; else $Class = ''; 59 59 $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>'; 60 60 } … … 62 62 } 63 63 $Result .= '</table>'; 64 return ($Result);64 return $Result; 65 65 } 66 66 67 67 function LoadDefaults() 68 68 { 69 foreach ($this->Definition['Items'] as $Index => $Item)70 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or69 foreach ($this->Definition['Items'] as $Index => $Item) 70 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 71 71 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 72 72 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 73 73 { 74 if (!array_key_exists($Index, $this->Values) and isset($Item['Default']))74 if (!array_key_exists($Index, $this->Values) and isset($Item['Default'])) 75 75 $this->Values[$Index] = $Item['Default']; 76 76 } … … 86 86 { 87 87 $Item = $this->Definition['Items'][$Index]; 88 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))89 { 90 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))88 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 89 { 90 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 91 91 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 92 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')92 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 93 93 $UseType = 'OneToMany'; 94 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')94 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 95 95 $UseType = 'Enumeration'; 96 96 } else $UseType = $Item['Type']; … … 107 107 'Rows' => array(), 108 108 ); 109 foreach ($this->Definition['Items'] as $Index => $Item)110 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))111 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or109 foreach ($this->Definition['Items'] as $Index => $Item) 110 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 111 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 112 112 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 113 113 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 114 114 { 115 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))116 { 117 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))115 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 116 { 117 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 118 118 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 119 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')119 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 120 120 $UseType = 'OneToMany'; 121 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')121 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 122 122 $UseType = 'Enumeration'; 123 123 } else $UseType = $Item['Type']; … … 126 126 'Type' => $Item['Type'], 'Values' => $this->Values, 127 127 'Filter' => $this->ValuesFilter[$Index])); 128 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];129 if (!$this->FormManager->Type->IsHidden($UseType))128 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 129 if (!$this->FormManager->Type->IsHidden($UseType)) 130 130 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 131 131 } 132 132 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.$this->Table($Table). 133 133 '</fieldset>'; 134 return ($Output);134 return $Output; 135 135 } 136 136 137 137 function ShowEditForm() 138 138 { 139 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';139 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit'; 140 140 $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock(). 141 141 '<div><input name="submit" type="submit" value="'.$this->Definition['SubmitText'].'" /> '. 142 142 '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>'; 143 return ($Output);143 return $Output; 144 144 } 145 145 … … 152 152 'Rows' => array(), 153 153 ); 154 if ($Context != '') $Context = $Context.'-';155 foreach ($this->Definition['Items'] as $Index => $Item)156 { 157 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;158 if ($Item['ReadOnly'] == false)159 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))160 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or154 if ($Context != '') $Context = $Context.'-'; 155 foreach ($this->Definition['Items'] as $Index => $Item) 156 { 157 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 158 if ($Item['ReadOnly'] == false) 159 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 160 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 161 161 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 162 162 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) … … 164 164 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 165 165 'Type' => $Item['Type'], 'Values' => $this->Values); 166 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];166 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 167 167 else unset($Parameters['Null']); 168 if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset'];168 if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset']; 169 169 else unset($Parameters['OnPreset']); 170 170 171 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))172 { 173 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))174 $this->FormManager->Type->RegisterType($Item['Type'], '', 175 $this->FormManager->FormTypes[$Item['Type']]); 176 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')171 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 172 { 173 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 174 $this->FormManager->Type->RegisterType($Item['Type'], '', 175 $this->FormManager->FormTypes[$Item['Type']]); 176 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 177 177 { 178 178 $UseType = 'OneToMany'; 179 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')179 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 180 180 $UseType = 'Enumeration'; 181 181 } else $UseType = $Item['Type']; 182 182 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters); 183 if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix'];183 if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix']; 184 184 185 185 $Caption = $Item['Caption'].':'; 186 if (array_key_exists($Index, $this->ValuesValidate) and186 if (array_key_exists($Index, $this->ValuesValidate) and 187 187 $this->ValuesValidate[$Index]) { 188 188 $Format = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'GetValidationFormat', array()); 189 if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>';189 if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>'; 190 190 $Caption = '<span style="color:red;">'.$Caption.'</span>'; 191 191 } 192 if (!$this->FormManager->Type->IsHidden($UseType))192 if (!$this->FormManager->Type->IsHidden($UseType)) 193 193 array_push($Table['Rows'], array($Caption, $Edit)); 194 194 else $Hidden .= $Edit; … … 197 197 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.$this->Table($Table). 198 198 $Hidden.'</fieldset>'; 199 return ($Output);199 return $Output; 200 200 } 201 201 202 202 function LoadValuesFromDatabase($Id) 203 203 { 204 foreach ($this->Definition['Items'] as $Index => $Item)205 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or204 foreach ($this->Definition['Items'] as $Index => $Item) 205 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 206 206 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 207 207 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 208 208 { 209 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))210 { 211 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))212 $this->FormManager->Type->RegisterType($Item['Type'], '', 213 $this->FormManager->FormTypes[$Item['Type']]); 214 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')215 $UseType = 'OneToMany'; 216 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')217 $UseType = 'Enumeration'; 218 } else $UseType = $Item['Type']; 219 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = '';209 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 210 { 211 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 212 $this->FormManager->Type->RegisterType($Item['Type'], '', 213 $this->FormManager->FormTypes[$Item['Type']]); 214 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 215 $UseType = 'OneToMany'; 216 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 217 $UseType = 'Enumeration'; 218 } else $UseType = $Item['Type']; 219 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = ''; 220 220 else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']); 221 221 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', … … 223 223 } 224 224 $Columns = implode(',', $Columns); 225 if (array_key_exists('SQL', $this->Definition))225 if (array_key_exists('SQL', $this->Definition)) 226 226 $SourceTable = '('.$this->Definition['SQL'].') AS `TX`'; 227 227 else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`'; 228 228 $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id); 229 229 $DbRow = $DbResult->fetch_array(); 230 foreach ($this->Definition['Items'] as $Index => $Item)231 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or230 foreach ($this->Definition['Items'] as $Index => $Item) 231 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 232 232 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 233 233 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 234 234 { 235 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))236 { 237 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))238 $this->FormManager->Type->RegisterType($Item['Type'], '', 239 $this->FormManager->FormTypes[$Item['Type']]); 240 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')241 $UseType = 'OneToMany'; 242 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')235 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 236 { 237 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 238 $this->FormManager->Type->RegisterType($Item['Type'], '', 239 $this->FormManager->FormTypes[$Item['Type']]); 240 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 241 $UseType = 'OneToMany'; 242 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 243 243 $UseType = 'Enumeration'; 244 244 } else $UseType = $Item['Type']; … … 253 253 { 254 254 $Values = array(); 255 foreach ($this->Definition['Items'] as $Index => $Item)256 { 257 if (array_key_exists($Index, $this->Values))258 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or255 foreach ($this->Definition['Items'] as $Index => $Item) 256 { 257 if (array_key_exists($Index, $this->Values)) 258 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 259 259 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 260 260 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) … … 263 263 'Type' => $Item['Type'], 'Values' => $this->Values); 264 264 265 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))266 { 267 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))268 $this->FormManager->Type->RegisterType($Item['Type'], '', 269 $this->FormManager->FormTypes[$Item['Type']]); 270 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')265 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 266 { 267 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 268 $this->FormManager->Type->RegisterType($Item['Type'], '', 269 $this->FormManager->FormTypes[$Item['Type']]); 270 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 271 271 { 272 272 $UseType = 'OneToMany'; 273 273 } 274 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')274 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 275 275 $UseType = 'Enumeration'; 276 276 } else $UseType = $Item['Type']; 277 277 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 278 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);279 } 280 } 281 if ($Id == 0)278 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); 279 } 280 } 281 if ($Id == 0) 282 282 { 283 283 $Values['Id'] = $Id; … … 294 294 function LoadValuesFromFormBlock($Context = '') 295 295 { 296 if ($Context != '') $Context = $Context.'-';296 if ($Context != '') $Context = $Context.'-'; 297 297 $Values = array(); 298 foreach ($this->Definition['Items'] as $Index => $Item)299 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))300 { 301 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or298 foreach ($this->Definition['Items'] as $Index => $Item) 299 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 300 { 301 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 302 302 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 303 303 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and … … 306 306 ($Item['ReadOnly'] != true)))) 307 307 { 308 //if (array_key_exists($Context.$Index, $_POST))309 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))310 { 311 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))308 //if (array_key_exists($Context.$Index, $_POST)) 309 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 310 { 311 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 312 312 $this->FormManager->Type->RegisterType($Item['Type'], '', 313 313 $this->FormManager->FormTypes[$Item['Type']]); 314 314 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 315 if ($CustomType == 'Reference')316 $UseType = 'OneToMany'; 317 else if ($CustomType == 'Enumeration')315 if ($CustomType == 'Reference') 316 $UseType = 'OneToMany'; 317 else if ($CustomType == 'Enumeration') 318 318 $UseType = 'Enumeration'; 319 319 } else $UseType = $Item['Type']; 320 320 $Parameters = array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values); 321 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];321 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 322 322 else unset($Parameters['Null']); 323 323 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad', … … 326 326 } else 327 327 { 328 if (isset($Item['Default'])) {329 if (isset($Item['Null']) and ($Item['Null'] == true))328 if (isset($Item['Default'])) { 329 if (isset($Item['Null']) and ($Item['Null'] == true)) 330 330 $Values[$Index] = null; 331 331 else $Values[$Index] = $Item['Default']; 332 332 } 333 333 } 334 return ($Values);334 return $Values; 335 335 } 336 336 … … 338 338 { 339 339 $Valid = true; 340 foreach ($this->Definition['Items'] as $Index => $Item)341 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or340 foreach ($this->Definition['Items'] as $Index => $Item) 341 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 342 342 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 343 343 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and … … 346 346 ($Item['ReadOnly'] != true)))) 347 347 { 348 //if (array_key_exists($Context.$Index, $_POST))349 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))350 { 351 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))348 //if (array_key_exists($Context.$Index, $_POST)) 349 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 350 { 351 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 352 352 $this->FormManager->Type->RegisterType($Item['Type'], '', 353 353 $this->FormManager->FormTypes[$Item['Type']]); 354 354 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 355 if ($CustomType == 'Reference')356 $UseType = 'OneToMany'; 357 else if ($CustomType == 'Enumeration')355 if ($CustomType == 'Reference') 356 $UseType = 'OneToMany'; 357 else if ($CustomType == 'Enumeration') 358 358 $UseType = 'Enumeration'; 359 359 } else $UseType = $Item['Type']; 360 360 361 361 $Parameters = array('Value' => $this->Values[$Index]); 362 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];362 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 363 363 else $Parameters['Null'] = false; 364 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',364 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate', 365 365 $Parameters)) { 366 366 $this->ValuesValidate[$Index] = true; … … 368 368 } 369 369 } 370 if ($Valid == false) throw new Exception('not validated');371 return ($Valid);370 if ($Valid == false) throw new Exception('not validated'); 371 return $Valid; 372 372 } 373 373 } … … 418 418 $this->Database->query('DELETE FROM DataType'); 419 419 420 foreach ($this->Type->TypeDefinitionList as $Name => $Type)420 foreach ($this->Type->TypeDefinitionList as $Name => $Type) 421 421 { 422 422 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"'); 423 if ($DbResult->num_rows == 0)423 if ($DbResult->num_rows == 0) 424 424 { 425 425 $this->Database->insert('DataType', array('Name' => $Name, … … 433 433 } 434 434 435 foreach ($this->Classes as $Class)436 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))435 foreach ($this->Classes as $Class) 436 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != '')) 437 437 { 438 438 $DbResult = $this->Database->query('SELECT * FROM information_schema.tables WHERE table_schema = "centrala_big" 439 439 AND table_name = "'.$Class['Table'].'" LIMIT 1'); 440 if ($DbResult->num_rows == 0) continue;440 if ($DbResult->num_rows == 0) continue; 441 441 442 442 echo($Class['Table'].'<br>'); 443 443 $Module = 1; 444 444 $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"'); 445 if ($DbResult->num_rows == 0)445 if ($DbResult->num_rows == 0) 446 446 { 447 447 $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module)); … … 455 455 } 456 456 457 foreach ($Class['Items'] as $Name => $Field)457 foreach ($Class['Items'] as $Name => $Field) 458 458 { 459 459 echo($Name.', '); 460 460 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"'); 461 if ($DbResult->num_rows > 0)461 if ($DbResult->num_rows > 0) 462 462 { 463 463 $DbRow = $DbResult->fetch_assoc(); … … 468 468 // Search parent type 469 469 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"'); 470 if ($DbResult->num_rows > 0)470 if ($DbResult->num_rows > 0) 471 471 { 472 472 $DbRow = $DbResult->fetch_assoc(); … … 480 480 481 481 $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')'); 482 if ($DbResult->num_rows == 0)482 if ($DbResult->num_rows == 0) 483 483 { 484 484 $this->Database->insert('ModelField', array('Name' => $Name,
Note:
See TracChangeset
for help on using the changeset viewer.