Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed May 14, 2016
1 parent 873b1ee commit 5a479df
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Model/Behavior/SequenceBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,17 @@ function ($connection) use ($table, $records, $config) {
}

if (is_array($record)) {
$entity = $table->newEntity();
$record = $entity->set($record, ['guard' => false]);
$record = $table->newEntity($record, [
'fieldList' => array_keys($record),
'accessibleFields' => [
$table->primaryKey() => true
]
]);
$record->isNew(false);
$record->dirty($table->primaryKey(), false);
}

$record->accessible($field);
$record->set($field, $order++);

$r = $table->save(
Expand Down Expand Up @@ -405,7 +411,7 @@ protected function _sync($fields, $conditions, $scope = null)
*
* @param string $direction Whether to increment or decrement the field.
*
* @return Cake\Database\Expression\QueryExpression QueryExpression to modify the order field
* @return \Cake\Database\Expression\QueryExpression QueryExpression to modify the order field
*/
protected function _getUpdateExpression($direction = '+')
{
Expand Down

0 comments on commit 5a479df

Please sign in to comment.