Permalink
Browse files

Merge branch 'sudhi-staging' of https://github.com/eddieajau/joomla-p…

…latform into sudhi-staging
  • Loading branch information...
2 parents e7940b1 + c067990 commit dd7323077a3acee14c517caac2b724b31002b42e @elinw committed Dec 16, 2011
@@ -218,15 +218,19 @@ public static function getAssetRules($asset, $recursive = false)
$query = $db->getQuery(true);
$query->select($recursive ? 'b.rules' : 'a.rules');
$query->from('#__assets AS a');
+ //sqlsrv change
+ $query->group($recursive ? 'b.id, b.rules, b.lft' : 'a.id, a.rules, a.lft');
// If the asset identifier is numeric assume it is a primary key, else lookup by name.
if (is_numeric($asset))
{
- $query->where('a.id = ' . (int) $asset);
+ // Get the root even if the asset is not found
+ $query->where('(a.id = ' . (int) $asset . ($recursive ? ' OR a.parent_id=0' : '') . ')');
}
else
{
- $query->where('a.name = ' . $db->quote($asset));
+ // Get the root even if the asset is not found
+ $query->where('(a.name = '.$db->quote($asset) . ($recursive ? ' OR a.parent_id=0' : '') . ')');
}
// If we want the rules cascading up to the global asset node we need a self-join.
@@ -289,7 +289,15 @@ protected function _load($id)
// Right join with c for category
$query->select('c.*');
- $query->select('CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as slug');
+ $case_when = ' CASE WHEN ';
+ $case_when .= $query->charLength('c.alias');
+ $case_when .= ' THEN ';
+ $c_id = $query->castAsChar('c.id');
+ $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
+ $case_when .= ' ELSE ';
+ $case_when .= $c_id.' END as slug';
+ $query->select($case_when);
+
$query->from('#__categories as c');
$query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')');
@@ -337,7 +345,10 @@ protected function _load($id)
}
// Group by
- $query->group('c.id');
+ $query->group('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
+ c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
+ c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
+ c.path, c.published, c.rgt, c.title, c.modified_user_id');
// Filter by language
if ($app->isSite() && $app->getLanguageFilter())
@@ -91,7 +91,7 @@ public function __construct($options = array())
{
if ($item->home)
{
- $this->_default[$item->language] = $item->id;
+ $this->_default[trim($item->language)] = $item->id;
}
// Decode the item params
@@ -41,6 +41,14 @@ public static function test();
abstract class JDatabase implements JDatabaseInterface
{
/**
+ * The name of the database.
+ *
+ * @var string
+ * @since 11.4
+ */
+ private $_database;
+
+ /**
* The name of the database driver.
*
* @var string
@@ -437,6 +445,8 @@ public function __call($method, $args)
protected function __construct($options)
{
// Initialise object variables.
+ $this->_database = (isset($options['database'])) ? $options['database'] : '';
+
$this->tablePrefix = (isset($options['prefix'])) ? $options['prefix'] : 'jos_';
$this->count = 0;
$this->errorNum = 0;
@@ -485,6 +495,19 @@ public function addQuoted($quoted)
abstract public function connected();
/**
+ * Drops a table from the database.
+ *
+ * @param string $table The name of the database table to drop.
+ * @param boolean $ifExists Optionally specify that the table must exist before it is dropped.
+ *
+ * @return JDatabase Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public abstract function dropTable($table, $ifExists = true);
+
+ /**
* Method to escape a string for usage in an SQL statement.
*
* @param string $text The string to be escaped.
@@ -585,6 +608,18 @@ public function getCount()
}
/**
+ * Gets the name of the database used by this conneciton.
+ *
+ * @return string
+ *
+ * @since 11.4
+ */
+ protected function getDatabase()
+ {
+ return $this->_database;
+ }
+
+ /**
* Returns a PHP date() function compliant date format for the database driver.
*
* @return string The format string.
@@ -1165,6 +1200,18 @@ public function loadRowList($key = null)
}
/**
+ * Locks a table in the database.
+ *
+ * @param string $tableName The name of the table to unlock.
+ *
+ * @return JDatabase Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public abstract function lockTable($tableName);
+
+ /**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on failure.
@@ -1317,6 +1364,21 @@ public function replacePrefix($sql, $prefix = '#__')
}
/**
+ * Renames a table in the database.
+ *
+ * @param string $oldTable The name of the table to be renamed
+ * @param string $newTable The new name for the table.
+ * @param string $backup Table prefix
+ * @param string $prefix For the table - used to rename constraints in non-mysql databases
+ *
+ * @return JDatabase Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public abstract function renameTable($oldTable, $newTable, $backup = null, $prefix = null);
+
+ /**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
@@ -1493,6 +1555,16 @@ public function updateObject($table, &$object, $key, $nulls = false)
return $this->query();
}
+ /**
+ * Unlocks tables in the database.
+ *
+ * @return JDatabase Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public abstract function unlockTables();
+
//
// Deprecated methods.
//
@@ -189,6 +189,7 @@ public function connected()
* @return JDatabaseMySQL Returns this object to support chaining.
*
* @since 11.1
+ * @throws JDatabaseException
*/
public function dropTable($tableName, $ifExists = true)
{
@@ -457,6 +458,23 @@ public function insertid()
}
/**
+ * Locks a table in the database.
+ *
+ * @param string $tableName The name of the table to unlock.
+ *
+ * @return JDatabaseMySQL Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public function lockTable($table)
+ {
+ $this->setQuery('LOCK TABLES '.$this->quoteName($table).' WRITE')->query();
+
+ return $this;
+ }
+
+ /**
* Execute the SQL statement.
*
* @return mixed A database cursor resource on success, boolean false on failure.
@@ -536,6 +554,26 @@ public function query()
}
/**
+ * Renames a table in the database.
+ *
+ * @param string $oldTable The name of the table to be renamed
+ * @param string $newTable The new name for the table.
+ * @param string $prefix Not used by MySQL.
+ * @param string $backup Not used by MySQL.
+ *
+ * @return JDatabase Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public function renameTable($oldTable, $newTable, $backup = null, $prefix = null)
+ {
+ $this->setQuery('RENAME TABLE '. $oldTable.' TO '. $newTable)->query();
+
+ return $this;
+ }
+
+ /**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
@@ -793,4 +831,21 @@ public function queryBatch($abortOnError = true, $transactionSafe = false)
}
return $error ? false : true;
}
+
+ /**
+ * Unlocks tables in the database.
+ *
+ * @param string $tableName The name of the table to unlock.
+ *
+ * @return JDatabaseMySQL Returns this object to support chaining.
+ *
+ * @since 11.4
+ * @throws JDatabaseException
+ */
+ public function unlockTables()
+ {
+ $this->setQuery('UNLOCK TABLES')->query();
+
+ return $this;
+ }
}
@@ -30,4 +30,33 @@ class JDatabaseSQLAzure extends JDatabaseSQLSrv
* @since 11.1
*/
public $name = 'sqlzure';
+
+ /**
+ * Get the current query or new JDatabaseQuery object.
+ *
+ * @param boolean $new False to return the last query set, True to return a new JDatabaseQuery object.
+ *
+ * @return mixed The current value of the internal SQL variable or a new JDatabaseQuery object.
+ *
+ * @since 11.1
+ * @throws DatabaseException
+ */
+ public function getQuery($new = false)
+ {
+ if ($new)
+ {
+ // Make sure we have a query class for this driver.
+ if (!class_exists('JDatabaseQuerySQLAzure'))
+ {
+ throw new DatabaseException(JText::_('JLIB_DATABASE_ERROR_MISSING_QUERY'));
+ }
+
+ return new JDatabaseQuerySQLAzure($this);
+ }
+ else
+ {
+ return $this->sql;
+ }
+ }
+
}
Oops, something went wrong. Retry.

0 comments on commit dd73230

Please sign in to comment.