function youtube_update()
{
    // convert version
    $version = osc_get_preference('youtube_version', 'youtube');
    if ($version == '') {
        $version = 12;
    }
    if ($version < 200) {
        $conn = DBConnectionClass::newInstance();
        $data = $conn->getOsclassDb();
        $dbCommand = new DBCommandClass($data);
        $dbCommand->query(sprintf('ALTER TABLE %s ADD COLUMN s_id VARCHAR(15) NOT NULL DEFAULT \'-no-id-\' AFTER s_youtube', YOUTUBE_TABLE));
        // update s_id
        $dbCommand->select();
        $dbCommand->from(YOUTUBE_TABLE);
        $rs = $dbCommand->get();
        if ($rs !== false) {
            $result = $rs->result();
            foreach ($result as $video) {
                $video_code = youtube_get_code_from_url($video['s_youtube']);
                $dbCommand->update(YOUTUBE_TABLE, array('s_id' => $video_code), array('fk_i_item_id' => $video['fk_i_item_id']));
            }
        }
        osc_set_preference('youtube_version', '200', 'youtube', 'STRING');
        osc_reset_preferences();
    }
}
Beispiel #2
0
 /**
  * Basic update. It returns false if the keys from $values or $where doesn't
  * match with the fields defined in the construct
  * 
  * @access public
  * @since unknown
  * @param array $values Array with keys (database field) and values
  * @param array $where
  * @return mixed It returns the number of affected rows if the update has been 
  * correct or false if an error happended
  */
 function update($values, $where)
 {
     if (!$this->checkFieldKeys(array_keys($values))) {
         return false;
     }
     if (!$this->checkFieldKeys(array_keys($where))) {
         return false;
     }
     $this->dao->from($this->getTableName());
     $this->dao->set($values);
     $this->dao->where($where);
     return $this->dao->update();
 }