Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Chris Berthe
2012-07-12 11:15:43 -04:00
25 changed files with 538 additions and 44 deletions

View File

@@ -218,9 +218,11 @@ abstract class Model {
{
$model = new static(array(), true);
if (static::$timestamps) $attributes['updated_at'] = new \DateTime;
$model->fill($attributes);
return $model->query()->where($model->key(), '=', $id)->update($attributes);
if (static::$timestamps) $model->timestamp();
return $model->query()->where($model->key(), '=', $id)->update($model->attributes);
}
/**
@@ -500,7 +502,7 @@ abstract class Model {
*/
public function changed($attribute)
{
return array_get($this->attributes, $attribute) !== array_get($this->original, $attribute);
return array_get($this->attributes, $attribute) != array_get($this->original, $attribute);
}
/**
@@ -536,7 +538,7 @@ abstract class Model {
foreach ($this->attributes as $key => $value)
{
if ( ! isset($this->original[$key]) or $value !== $this->original[$key])
if ( ! array_key_exists($key, $this->original) or $value !== $this->original[$key])
{
$dirty[$key] = $value;
}
@@ -725,7 +727,7 @@ abstract class Model {
{
foreach (array('attributes', 'relationships') as $source)
{
if (array_key_exists($key, $this->$source)) return true;
if (array_key_exists($key, $this->$source)) return !is_null($this->$source[$key]);
}
if (method_exists($this, $key)) return true;

View File

@@ -140,7 +140,7 @@ class Query {
*/
public function select($columns = array('*'))
{
$this->selects = (array) $columns;
$this->selects = is_array($columns) ? $columns : array($columns);
return $this;
}
@@ -395,7 +395,7 @@ class Query {
}
/**
* Add a nested where condition to the query.
* Add nested constraints to the query.
*
* @param Closure $callback
* @param string $connector
@@ -403,24 +403,7 @@ class Query {
*/
public function where_nested($callback, $connector = 'AND')
{
$type = 'where_nested';
// To handle a nested where statement, we will actually instantiate a new
// Query instance and run the callback over that instance, which will
// allow the developer to have a fresh query instance
$query = new Query($this->connection, $this->grammar, $this->from);
call_user_func($callback, $query);
// Once the callback has been run on the query, we will store the nested
// query instance on the where clause array so that it's passed to the
// query's query grammar instance when building.
if ($query->wheres !== null)
{
$this->wheres[] = compact('type', 'query', 'connector');
}
$this->bindings = array_merge($this->bindings, $query->bindings);
call_user_func($callback, $this);
return $this;
}

View File

@@ -99,7 +99,7 @@ class MySQL extends Grammar {
*/
protected function unsigned(Table $table, Fluent $column)
{
if ($column->type == 'integer' && $column->unsigned)
if ($column->type == 'integer' && ($column->unsigned || $column->increment))
{
return ' UNSIGNED';
}