- Timestamp:
- Dec 16, 2008, 1:47:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
types/PointerOneToOne.php
r30 r31 23 23 { 24 24 //print_r($Type); 25 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => 'Id='.$Item['Value']));25 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => $List['IdName'].'='.$Item['Value'])); 26 26 $DbRow = $DbResult->fetch_assoc(); 27 27 $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0); … … 32 32 } 33 33 $Columns = substr($Columns, 0, -1); 34 if($Columns == '') $Columns = ' Id AS Name, Id';35 else $Columns = 'CONCAT('.$Columns.') AS Name, Id';36 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => 'Id='.$Item['Value']));34 if($Columns == '') $Columns = '`'.$List['IdName'].'` AS `Name`, `'.$List['IdName'].'`'; 35 else $Columns = 'CONCAT('.$Columns.') AS `Name`, `'.$List['IdName'].'`'; 36 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => $List['IdName'].'='.$Item['Value'])); 37 37 //echo($Database->LastQuery); 38 38 if($DbResult->num_rows > 0) … … 51 51 foreach($List['Items'] as $ListItem) 52 52 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 53 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';54 $DbResult = $Database-> query('SELECT '.$Columns.' FROM `'.$TargetTable.'`');53 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, `'.$List['IdName'].'`'; 54 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns)); 55 55 //echo($Database->LastQuery); 56 56 if($DbResult->num_rows > 0) … … 69 69 70 70 $Type = GetTypeDefinition($Item['Type']); 71 $List = GetListDefinition($Type['Parameters'][0]); 71 72 $TargetTable = $Type['Parameters'][0]; 72 73 $TargetName = $this->GetTablePointerName($Type, $Item); 73 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName[ 'Id'].'">'.$TargetName['Name'].'</a>';74 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName[$List['IdName']].'">'.$TargetName['Name'].'</a>'; 74 75 return($Output); 75 76 } … … 80 81 81 82 $Type = $Types[$Item['Type']]; 83 $List = GetListDefinition($Type['Parameters'][0]); 82 84 $Output = '<select name="'.$Item['Name'].'">'; 83 85 $TargetNameList = $this->GetTablePointerNameList($Type, $Item); … … 85 87 foreach($TargetNameList as $TargetName) 86 88 { 87 if($Item['Value'] == $TargetName[ 'Id']) $Selected = ' selected="1"'; else $Selected = '';88 $Output .= '<option value="'.$TargetName[ 'Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';89 if($Item['Value'] == $TargetName[$List['IdName']]) $Selected = ' selected="1"'; else $Selected = ''; 90 $Output .= '<option value="'.$TargetName[$List['IdName']].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 89 91 } 90 92 $Output .= '</select>';
Note:
See TracChangeset
for help on using the changeset viewer.