nicer save-function

This commit is contained in:
Cornelius Weiß 2005-02-14 12:03:06 +00:00
parent b6cc2d6d7b
commit 3d31b0e7fe
2 changed files with 10 additions and 17 deletions

View File

@ -115,26 +115,19 @@ class so_resources
@function save @function save
@abstract saves a resource including binary datas @abstract saves a resource including binary datas
@param array $resource key => value @param array $resource key => value
@return array with key => value or false if not found @return bool succsess or not!
*/ */
function save($resource) function save($resource)
{ {
$where = array('id' => $resource['id']); $where = array('id' => $resource['id']);
$data = array( 'name' => $resource['name'],
'cat_id' => $resource['cat_id'], // get rid of the non storeable datas
'short_description' => $resource['short_description'], $tabledef = $this->db->metadata($table=$this->rs_table,$full=false);
'long_description' => $resource['long_description'], foreach($tabledef as $n => $fielddef)
'location' => $resource['location'], {
'quantity' => $resource['quantity'], $data[$fielddef['name']] = $resource[$fielddef['name']];
'useable' => $resource['useable'], }
'bookable' => $resource['bookable'],
'buyable' => $resource['buyable'],
'prize' => $resource['prize'],
'accessories' => $resource['accessories'],
'picture_src' => $resource['picture_src'],
'picture_thumb' => $resource['picture_thumb'],
'picture' => $resource['picture']
);
return $this->db->insert($this->rs_table,$data,$where,__LINE__,__FILE__) ? true : false; return $this->db->insert($this->rs_table,$data,$where,__LINE__,__FILE__) ? true : false;
} }