Esempio n. 1
0
 /**
  * Preforms a select query
  *
  * Use for SELECT and anything that returns rows.
  *
  * @param string $sql 		A full SQL query to run.
  * @param string $prefix 	A table prefix, this will be replaced
  *
  * @return object A KRowset.
  */
 public function select($sql, $offset = 0, $limit = 0)
 {
     // Make sure the active language differs from the primary language
     if ($this->_lang_active == $this->_lang_primary || empty($this->_lang_active)) {
         return parent::select($sql, $offset, $limit);
     }
     // Match all of the database tables in the query using the prefix modifier
     if (!preg_match_all($this->_tables_regex, $sql, $tables)) {
         return parent::select($sql, $offset, $limit);
     }
     // For each found table iterate over and lets modify the translatable ones
     for ($i = 0, $n = count($tables[1]); $i < $n; $i++) {
         if ($this->isTableTranslatable($tables[1][$i])) {
             $table = $this->_object->nameQuote('#__' . strtolower($this->_lang_active) . '_' . $tables[1][$i]);
             $sql = str_replace($tables[0][$i], $table . $tables[2][$i], $sql);
         }
     }
     return parent::select($sql, $offset, $limit);
 }