Changeset 447 for trunk/Common
- Timestamp:
- Oct 16, 2012, 8:26:33 PM (13 years ago)
- Location:
- trunk/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Database.php
r438 r447 88 88 { 89 89 $Name .= ',`'.$Key.'`'; 90 if(!in_array($Value, $this->Functions)) $Value = $this->PDO->quote($Value); 90 if(!in_array($Value, $this->Functions)) 91 { 92 if($Value == NULL) $Value = 'NULL'; 93 else $Value = $this->PDO->quote($Value); 94 } 91 95 $Values .= ','.$Value; 92 96 } … … 102 106 foreach($Data as $Key => $Value) 103 107 { 104 if(!in_array($Value, $this->Functions)) $Value = $this->PDO->quote($Value); 108 if(!in_array($Value, $this->Functions)) 109 { 110 if($Value == NULL) $Value = 'NULL'; 111 else $Value = $this->PDO->quote($Value); 112 } 105 113 $Values .= ', `'.$Key.'`='.$Value; 106 114 } … … 115 123 foreach($Data as $Key => $Value) 116 124 { 117 if(!in_array($Value, $this->Functions)) $Value = $this->PDO->quote($Value); 125 if(!in_array($Value, $this->Functions)) 126 { 127 if($Value == NULL) $Value = 'NULL'; 128 else $Value = $this->PDO->quote($Value); 129 } 118 130 $Name .= ',`'.$Key.'`'; 119 131 $Values .= ','.$Value; -
trunk/Common/Forms.php
r445 r447 71 71 { 72 72 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 73 if(array_key_exists($Item['Type'], $FormTypes)) 74 { 75 if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList)) 76 $System->Type->RegisterType($Item['Type'], '', 77 $FormTypes[$Item['Type']]); 78 if($FormTypes[$Item['Type']]['Type'] == 'Reference') 79 $UseType = 'OneToMany'; 80 else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration') 81 $UseType = 'Enumeration'; 82 } else $UseType = $Item['Type']; 83 $Edit = ''.$System->Type->ExecuteTypeEvent($UseType, 'OnEdit', 84 array('Value' => $this->Values[$Index], 'Name' => $Index, 85 'Type' => $Item['Type'])).''; 73 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 74 'Type' => $Item['Type']); 75 if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 76 else unset($Parameters['Null']); 77 78 if(array_key_exists($Item['Type'], $FormTypes)) 79 { 80 if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList)) 81 $System->Type->RegisterType($Item['Type'], '', 82 $FormTypes[$Item['Type']]); 83 if($FormTypes[$Item['Type']]['Type'] == 'Reference') 84 { 85 $UseType = 'OneToMany'; 86 } else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration') 87 $UseType = 'Enumeration'; 88 } else $UseType = $Item['Type']; 89 $Edit = ''.$System->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters).''; 86 90 87 91 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); … … 131 135 { 132 136 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 133 if(array_key_exists($Item['Type'], $FormTypes)) 134 { 135 if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList)) 136 $System->Type->RegisterType($Item['Type'], '', 137 $FormTypes[$Item['Type']]); 138 if($FormTypes[$Item['Type']]['Type'] == 'Reference') 139 $UseType = 'OneToMany'; 140 else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration') 141 $UseType = 'Enumeration'; 142 } else $UseType = $Item['Type']; 143 $Values[$Index] = ''.$System->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', 144 array('Value' => $this->Values[$Index], 'Name' => $Index, 145 'Type' => $Item['Type'])).''; 137 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 138 'Type' => $Item['Type']); 139 140 if(array_key_exists($Item['Type'], $FormTypes)) 141 { 142 if(!array_key_exists($Item['Type'], $System->Type->TypeDefinitionList)) 143 $System->Type->RegisterType($Item['Type'], '', 144 $FormTypes[$Item['Type']]); 145 if($FormTypes[$Item['Type']]['Type'] == 'Reference') 146 { 147 $UseType = 'OneToMany'; 148 } 149 else if($FormTypes[$Item['Type']]['Type'] == 'Enumeration') 150 $UseType = 'Enumeration'; 151 } else $UseType = $Item['Type']; 152 $Values[$Index] = ''.$System->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters).''; 146 153 147 154 //echo($DbRow[$Index].'='.$this->Values[$Index].'<br/>'); … … 152 159 $DbResult = $Database->insert($this->Definition['Table'], $Values); 153 160 } else 154 $DbResult = $Database->update($this->Definition['Table'], 'Id='.$Id, $Values);161 $DbResult = $Database->update($this->Definition['Table'], 'Id='.$Id, $Values); 155 162 //echo($Database->LastQuery); 156 163 } -
trunk/Common/Types/OneToMany.php
r442 r447 26 26 if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition']; 27 27 else $Where = ''; 28 print_r($Item); 29 if(array_key_exists('Null', $Item) and $Item['Null']) 30 { 31 if($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 32 $Output .= '<option value=""'.$Selected.'></option>'; 33 } 28 34 $DbResult = $this->System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY `Name`'); 29 35 while($DbRow = $DbResult->fetch_assoc()) … … 38 44 function OnLoad($Item) 39 45 { 40 return($_POST[$Item['Name']]); 46 if($_POST[$Item['Name']] == '') return(NULL); 47 else return($_POST[$Item['Name']]); 48 } 49 50 function OnLoadDb($Item) 51 { 52 if($Item['Value'] == '') return(NULL); 53 else return($Item['Value']); 41 54 } 42 55 }
Note:
See TracChangeset
for help on using the changeset viewer.