function addArticle($dataContent, $data) { $db = JFactory::getDbo(); $contentTable = new JTableContent($db); $contentTable->bind($dataContent); if ($contentTable->check()) { $contentTable->store(); if ($contentTable->id) { $data->article_id = $contentTable->id; addMinicck($data); } } }
/** * Overrides JTableContent::store. Stores event info. * * @param boolean $updateNulls True to update fields even if they are null. * * @return boolean True on success. */ public function store($updateNulls = false) { global $shareddb, $sharedtbl, $sharedlinktbl, $koid; // If a primary key exists update the object, otherwise insert it. if ($this->hasPrimaryKey()) { $fields = array($this->_db->quoteName('start_time') . ' = ' . $this->_db->quote($this->start_time), $this->_db->quoteName('end_time') . ' = ' . $this->_db->quote($this->end_time), $this->_db->quoteName('whole_day') . ' = ' . $this->whole_day, $this->_db->quoteName('location') . ' = ' . $this->_db->quote($this->location), $this->_db->quoteName('url') . ' = ' . $this->_db->quote($this->url), $this->_db->quoteName('tickets') . ' = ' . $this->_db->quote($this->tickets), $this->_db->quoteName('contact') . ' = ' . $this->_db->quote($this->contact), $this->_db->quoteName('chargeable') . ' = ' . $this->_db->quote($this->chargeable), $this->_db->quoteName('children') . ' = ' . $this->_db->quote($this->children)); $query = $this->_db->getQuery(true)->update($this->_db->quoteName($shareddb) . '.' . $this->_db->quoteName($sharedtbl))->set($fields)->where($this->_db->quoteName('article_id') . ' = ' . $this->article_id . ' AND ' . $this->_db->quoteName('koid') . ' = ' . $this->_db->quote($this->koid)); $this->_db->setQuery($query); $this->_db->execute(); /* * Since parent::store() tries to store all of the objects properties * to #__content, we have to set free those properties that we don't * want to store there. But we will need those properties later, so * let's save them as temporary local variables first. */ $columns = array('article_id' => $this->article_id, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'whole_day' => $this->whole_day, 'location' => $this->location, 'url' => $this->url, 'tickets' => $this->tickets, 'contact' => $this->contact, 'koid' => $this->koid, 'children' => $this->children, 'chargeable' => $this->chargeable); // Free properties $this->article_id = null; $this->start_time = null; $this->end_time = null; $this->whole_day = null; $this->location = null; $this->url = null; $this->tickets = null; $this->contact = null; $this->koid = null; $this->chargeable = null; $this->children = null; $this->showdate = null; $this->id = $columns['article_id']; $r = parent::store($updateNulls); // return properties $this->article_id = $columns['article_id']; $this->start_time = $columns['start_time']; $this->end_time = $columns['end_time']; $this->whole_day = $columns['whole_day']; $this->location = $columns['location']; $this->url = $columns['url']; $this->tickets = $columns['tickets']; $this->contact = $columns['contact']; $this->koid = $columns['koid']; $this->children = $columns['children']; $this->chargeable = $columns['chargeable']; return $r; } else { /* * Since parent::store() tries to store all of the objects properties * to #__content, we have to set free those properties that we don't * want to store there. But we will need those properties later, so * let's save them as temporary local variables first. */ $columns = array('article_id' => $this->article_id, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'whole_day' => $this->whole_day, 'location' => $this->location, 'url' => $this->url, 'tickets' => $this->tickets, 'contact' => $this->contact, 'koid' => $this->koid, 'children' => $this->children, 'chargeable' => $this->chargeable); // Free properties $this->article_id = null; $this->start_time = null; $this->end_time = null; $this->whole_day = null; $this->location = null; $this->url = null; $this->tickets = null; $this->contact = null; $this->koid = null; $this->children = null; $this->chargeable = null; $this->showdate = null; if (!parent::store()) { return false; } // return properties $this->article_id = $columns['article_id']; $this->start_time = $columns['start_time']; $this->end_time = $columns['end_time']; $this->whole_day = $columns['whole_day']; $this->location = $columns['location']; $this->url = $columns['url']; $this->tickets = $columns['tickets']; $this->contact = $columns['contact']; $this->koid = $columns['koid']; $this->chargeable = $columns['chargeable']; $this->children = $columns['children']; $query = $this->_db->getQuery(true)->insert($this->_db->quoteName($shareddb) . '.' . $this->_db->quoteName($sharedtbl))->columns(array_keys($columns))->values($this->getArticleId() . ', ' . $this->_db->quote($this->start_time) . ', ' . $this->_db->quote($this->end_time) . ', ' . $this->whole_day . ', ' . $this->_db->quote($this->location) . ', ' . $this->_db->quote($this->url) . ', ' . $this->_db->quote($this->tickets) . ', ' . $this->_db->quote($this->contact) . ', ' . $this->_db->quote($koid) . ', ' . $this->children . ', ' . $this->chargeable); $this->_db->setQuery($query); return $this->_db->execute(); } }