Skip to content

Commit

Permalink
Merge branch 'sudhi-staging' of https://github.com/eddieajau/joomla-p…
Browse files Browse the repository at this point in the history
…latform into sudhi-staging
  • Loading branch information
elinw committed Dec 16, 2011
2 parents e7940b1 + c067990 commit dd73230
Show file tree
Hide file tree
Showing 23 changed files with 489 additions and 68 deletions.
8 changes: 6 additions & 2 deletions libraries/joomla/access/access.php
Expand Up @@ -218,15 +218,19 @@ public static function getAssetRules($asset, $recursive = false)
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->select($recursive ? 'b.rules' : 'a.rules'); $query->select($recursive ? 'b.rules' : 'a.rules');
$query->from('#__assets AS a'); $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 the asset identifier is numeric assume it is a primary key, else lookup by name.
if (is_numeric($asset)) 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 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. // If we want the rules cascading up to the global asset node we need a self-join.
Expand Down
15 changes: 13 additions & 2 deletions libraries/joomla/application/categories.php
Expand Up @@ -289,7 +289,15 @@ protected function _load($id)


// Right join with c for category // Right join with c for category
$query->select('c.*'); $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->from('#__categories as c');
$query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')'); $query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')');


Expand Down Expand Up @@ -337,7 +345,10 @@ protected function _load($id)
} }


// Group by // 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 // Filter by language
if ($app->isSite() && $app->getLanguageFilter()) if ($app->isSite() && $app->getLanguageFilter())
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/application/menu.php
Expand Up @@ -91,7 +91,7 @@ public function __construct($options = array())
{ {
if ($item->home) if ($item->home)
{ {
$this->_default[$item->language] = $item->id; $this->_default[trim($item->language)] = $item->id;
} }


// Decode the item params // Decode the item params
Expand Down
72 changes: 72 additions & 0 deletions libraries/joomla/database/database.php
Expand Up @@ -40,6 +40,14 @@ public static function test();
*/ */
abstract class JDatabase implements JDatabaseInterface abstract class JDatabase implements JDatabaseInterface
{ {
/**
* The name of the database.
*
* @var string
* @since 11.4
*/
private $_database;

/** /**
* The name of the database driver. * The name of the database driver.
* *
Expand Down Expand Up @@ -437,6 +445,8 @@ public function __call($method, $args)
protected function __construct($options) protected function __construct($options)
{ {
// Initialise object variables. // Initialise object variables.
$this->_database = (isset($options['database'])) ? $options['database'] : '';

$this->tablePrefix = (isset($options['prefix'])) ? $options['prefix'] : 'jos_'; $this->tablePrefix = (isset($options['prefix'])) ? $options['prefix'] : 'jos_';
$this->count = 0; $this->count = 0;
$this->errorNum = 0; $this->errorNum = 0;
Expand Down Expand Up @@ -484,6 +494,19 @@ public function addQuoted($quoted)
*/ */
abstract public function connected(); 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. * Method to escape a string for usage in an SQL statement.
* *
Expand Down Expand Up @@ -584,6 +607,18 @@ public function getCount()
return $this->count; return $this->count;
} }


/**
* 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. * Returns a PHP date() function compliant date format for the database driver.
* *
Expand Down Expand Up @@ -1164,6 +1199,18 @@ public function loadRowList($key = null)
return $array; return $array;
} }


/**
* 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. * Execute the SQL statement.
* *
Expand Down Expand Up @@ -1316,6 +1363,21 @@ public function replacePrefix($sql, $prefix = '#__')
return $literal; return $literal;
} }


/**
* 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. * Select a database for use.
* *
Expand Down Expand Up @@ -1493,6 +1555,16 @@ public function updateObject($table, &$object, $key, $nulls = false)
return $this->query(); 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. // Deprecated methods.
// //
Expand Down
55 changes: 55 additions & 0 deletions libraries/joomla/database/database/mysql.php
Expand Up @@ -189,6 +189,7 @@ public function connected()
* @return JDatabaseMySQL Returns this object to support chaining. * @return JDatabaseMySQL Returns this object to support chaining.
* *
* @since 11.1 * @since 11.1
* @throws JDatabaseException
*/ */
public function dropTable($tableName, $ifExists = true) public function dropTable($tableName, $ifExists = true)
{ {
Expand Down Expand Up @@ -456,6 +457,23 @@ public function insertid()
return mysql_insert_id($this->connection); return mysql_insert_id($this->connection);
} }


/**
* 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. * Execute the SQL statement.
* *
Expand Down Expand Up @@ -535,6 +553,26 @@ public function query()
return $this->cursor; return $this->cursor;
} }


/**
* 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. * Select a database for use.
* *
Expand Down Expand Up @@ -793,4 +831,21 @@ public function queryBatch($abortOnError = true, $transactionSafe = false)
} }
return $error ? false : true; 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;
}
} }
29 changes: 29 additions & 0 deletions libraries/joomla/database/database/sqlazure.php
Expand Up @@ -30,4 +30,33 @@ class JDatabaseSQLAzure extends JDatabaseSQLSrv
* @since 11.1 * @since 11.1
*/ */
public $name = 'sqlzure'; 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;
}
}

} }

0 comments on commit dd73230

Please sign in to comment.