Пример #1
0
 /**
  * Saves a (new or existing) page
  *
  * @param	array	Page data
  * @param	array	Conditions - Must be specified if updating an existing record.
  *
  * @return	int|mixed	If it is a new page, the pageid will be returned
  */
 public function save(array $data, array $conditions = array())
 {
     $this->checkHasAdminPermission('canusesitebuilder');
     $db = vB::getDbAssertor();
     // We should unset 'pageid' from data
     // 'pageid' should go to conditions parameter.
     unset($data['pageid']);
     // Get page table structure
     $structure = vB_dB_Assertor::fetchTableStructure('page');
     foreach ($data as $k => $v) {
         if (!in_array($k, $structure['structure'])) {
             unset($data[$k]);
         }
     }
     if (!empty($conditions)) {
         return $db->update('page', $data, $conditions);
     } else {
         return $db->insert('page', $data);
     }
 }