added support for database table prefixes.

This commit is contained in:
Taylor Otwell
2012-01-29 13:07:15 -06:00
parent 97fcea1e51
commit 1ec6fc766c
6 changed files with 73 additions and 22 deletions

View File

@@ -9,6 +9,45 @@ abstract class Grammar {
*/
protected $wrapper = '"%s"';
/**
* The database connection instance for the grammar.
*
* @var Connection
*/
protected $connection;
/**
* Create a new database grammar instance.
*
* @param Connection $connection
* @return void
*/
public function __construct(Connection $connection)
{
$this->connection = $connection;
}
/**
* Wrap a table in keyword identifiers.
*
* @param string $table
* @return string
*/
public function wrap_table($table)
{
$prefix = '';
// Tables may be prefixed with a string. This allows developers to
// prefix tables by application on the same database which may be
// required in some brown-field situations.
if (isset($this->connection->config['prefix']))
{
$prefix = $this->connection->config['prefix'];
}
return $this->wrap($prefix.$table);
}
/**
* Wrap a value in keyword identifiers.
*