refactoring and working on redis.

This commit is contained in:
Taylor Otwell
2011-10-19 22:44:02 -05:00
parent ba29a0bd38
commit df9130dafa
8 changed files with 224 additions and 49 deletions

View File

@@ -22,7 +22,16 @@ class Grammar {
*
* @var array
*/
protected $components = array('aggregate', 'selects', 'from', 'joins', 'wheres', 'orderings', 'limit', 'offset');
protected $components = array(
'aggregate',
'selects',
'from',
'joins',
'wheres',
'orderings',
'limit',
'offset'
);
/**
* Compile a SQL SELECT statement from a Query instance.
@@ -272,9 +281,12 @@ class Grammar {
// every insert to the table.
$columns = $this->columnize(array_keys(reset($values)));
// We need to create a string of comma-delimited insert segments. Each segment
// contains PDO place-holders for each value being inserted into the table.
$parameters = implode(', ', array_fill(0, count($values), '('.$this->parameterize(reset($values)).')'));
// Build the list of parameter place-holders for the array of values bound
// to the query. Each insert statement should have the same number of bound
// parameters, so we can just use the first array of values.
$parameters = $this->parameterize(reset($values));
$parameters = implode(', ', array_fill(0, count($values), '('.$parameters.')'));
return 'INSERT INTO '.$this->wrap($query->from).' ('.$columns.') VALUES '.$parameters;
}

View File

@@ -40,7 +40,7 @@ class Manager {
if (is_null($config))
{
throw new \Exception("Database connection configuration is not defined for connection [$connection].");
throw new \Exception("Database connection is not defined for connection [$connection].");
}
static::$connections[$connection] = new Connection(static::connect($config), $config);