Commit faa2eec3 authored by Taylor Otwell's avatar Taylor Otwell

consolidate database methods into db::query.

parent 42b9d1e0
......@@ -140,50 +140,23 @@ class Connection {
{
list($statement, $result) = $this->execute($sql, $bindings);
// The result we return depends on the type of query executed against the
// database. On SELECT clauses, we will return the result set, for update
// and deletes we will return the affected row count. And for all other
// queries we'll just return the boolean result.
if (stripos($sql, 'select') === 0)
{
return $statement->fetchAll(PDO::FETCH_CLASS, 'stdClass');
}
/**
* Execute a SQL UPDATE query and return the affected row count.
*
* @param string $sql
* @param array $bindings
* @return int
*/
public function update($sql, $bindings = array())
elseif (stripos($sql, 'update') === 0 or stripos($sql, 'delete') === 0)
{
list($statement, $result) = $this->execute($sql, $bindings);
return $statement->rowCount();
}
/**
* Execute a SQL DELETE query and return the affected row count.
*
* @param string $sql
* @param array $bindings
* @return int
*/
public function delete($sql, $bindings = array())
else
{
list($statement, $result) = $this->execute($sql, $bindings);
return $statement->rowCount();
}
/**
* Execute an SQL query and return the boolean result of the PDO statement.
*
* @param string $sql
* @param array $bindings
* @return bool
*/
public function statement($sql, $bindings = array())
{
list($statement, $result) = $this->execute($sql, $bindings);
return $result;
}
}
/**
* Execute a SQL query against the connection.
......
......@@ -717,7 +717,7 @@ class Query {
$sql = $this->grammar->insert($this, $values);
return $this->connection->statement($sql, $bindings);
return $this->connection->query($sql, $bindings);
}
/**
......@@ -731,7 +731,7 @@ class Query {
{
$sql = $this->grammar->insert($this, $values);
$this->connection->statement($sql, array_values($values));
$this->connection->query($sql, array_values($values));
// Some database systems (Postgres) require a sequence name to be
// given when retrieving the auto-incrementing ID, so we'll pass
......@@ -797,7 +797,7 @@ class Query {
$sql = $this->grammar->update($this, $values);
return $this->connection->update($sql, $bindings);
return $this->connection->query($sql, $bindings);
}
/**
......@@ -820,7 +820,7 @@ class Query {
$sql = $this->grammar->delete($this);
return $this->connection->delete($sql, $this->bindings);
return $this->connection->query($sql, $this->bindings);
}
/**
......
......@@ -89,7 +89,7 @@ class Schema {
// needs multiple queries to complete.
foreach ((array) $statements as $statement)
{
$connection->statement($statement);
$connection->query($statement);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment