Changeset 28 for database_list.php
- Timestamp:
- Dec 8, 2008, 11:06:23 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
database_list.php
r24 r28 7 7 function AddItem($TableId, $Values) 8 8 { 9 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE I temId='.$TableId.' ORDER BY Id DESC LIMIT 1');9 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId); 10 10 $DbRow = $DbResult->fetch_assoc(); 11 11 $TableName = $DbRow['TableName']; 12 12 13 $Values['Author'] = $this->System->Modules['User']->User['ItemId'];14 $Values['CreationTime'] = 'NOW()';15 $Values['ValidTimeFrom'] = 'NOW()';16 $DbResult = $this->Database->select($TableName, 'MAX(ItemId)');17 $DbRow = $DbResult->fetch_row();18 $AutoincrementId = $DbRow[0];19 $Values['ItemId'] = $AutoincrementId + 1;20 13 $this->Database->insert($TableName, $Values); 21 return($ Values['ItemId']);14 return($this->Database->insert_id); 22 15 } 23 16 24 17 function DeleteItem($TableId, $ItemId) 25 18 { 26 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE I temId='.$TableId.' ORDER BY Id DESC LIMIT 1');19 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId); 27 20 $DbRow = $DbResult->fetch_assoc(); 28 21 $TableName = $DbRow['TableName']; 29 30 $DbResult = $this->Database->select($TableName, 'Id', 'ItemId='.$ItemId.' ORDER BY Id DESC LIMIT 1'); 31 $DbRow = $DbResult->fetch_assoc(); 32 $this->Database->update($TableName, 'Id='.$DbRow['Id'], array('DeletionTime' => 'NOW()')); 22 $this->Database->delete($TableName, 'Id='.$ItemId, array('DeletionTime' => 'NOW()')); 33 23 } 34 24 35 25 function EditItem($TableId, $Values, $ItemId) 36 26 { 37 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE I temId='.$TableId.' ORDER BY Id DESC LIMIT 1');27 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId); 38 28 $DbRow = $DbResult->fetch_assoc(); 39 29 $TableName = $DbRow['TableName']; 40 30 $this->DeleteItem($TableId, $ItemId); 41 $Values['ItemId'] = $ItemId; 42 $Values['Author'] = $this->System->Modules['User']->User['ItemId']; 43 $Values['CreationTime'] = 'NOW()'; 44 $Values['ValidTimeFrom'] = 'NOW()'; 45 $this->Database->insert($TableName, $Values); 31 $Values['Id'] = $ItemId; 32 $this->Database->replace($TableName, $Values); 46 33 } 47 34 }
Note:
See TracChangeset
for help on using the changeset viewer.