/** * Execute the SQL statement. * * @param boolean $replacePrefixQuotes Replace the prefixes inside the quotes too * * @return mixed A database cursor resource on success, boolean false on failure. * * @since 12.1 * @throws RuntimeException */ public function execute($replacePrefixQuotes = false) { if ($replacePrefixQuotes) { $this->sql = $this->replacePrefix((string) $this->sql, '#__', $replacePrefixQuotes); } return parent::execute(); }
/** * {@inheritdoc} * * @return bool|mixed */ public function execute() { $language = JFactory::getLanguage(); $app = JFactory::getApplication(); // Check if the user is trying to insert something in the front-end in different language if ($this->getQueryType((string) $this->sql) === self::INSERT_QUERY && $language->getTag() !== NenoSettings::get('source_language') && $app->isSite() && !$this->isNenoSql((string) $this->sql)) { $tables = null; preg_match('/insert into (\\w+)/', $this->sql, $tables); if (!empty($tables)) { /* @var $table NenoContentElementTable */ $table = NenoContentElementTable::load(array('table_name' => $tables[1])); if (!empty($table) && $table->isTranslate()) { $language->load('com_neno', JPATH_ADMINISTRATOR); throw new Exception(JText::_('COM_NENO_CONTENT_IN_OTHER_LANGUAGES_ARE_NOT_ALLOWED')); } } } else { try { // Get query type $queryType = $this->getQueryType((string) $this->sql); $result = parent::execute(); // If the query is creating/modifying/deleting a record, let's do the same on the shadow tables if (($queryType === self::INSERT_QUERY || $queryType === self::DELETE_QUERY || $queryType === self::UPDATE_QUERY || $queryType === self::REPLACE_QUERY) && $this->hasToBeParsed((string) $this->sql)) { $sql = $this->sql; foreach ($this->languages as $language) { $newSql = $this->replaceTableNameStatements((string) $sql, $language->lang_code); // Execute query if they are different. if ($newSql != $sql) { $this->executeQuery($newSql, false); } } } return $result; } catch (RuntimeException $ex) { NenoLog::log($ex->getMessage(), NenoLog::PRIORITY_ERROR); } } return false; }