Skip to content

Commit

Permalink
renamed batch/performScenario -> batch/query
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Jan 31, 2017
1 parent e7b0e12 commit c478145
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function insert($runValidation = true, $attributes = null, $options = [])

$values = $this->getDirtyAttributes($attributes);
$data = array_merge($values, $options, ['id' => $this->getOldPrimaryKey()]);
$result = $this->performScenario('insert', $data);
$result = $this->query('insert', $data);

$pk = static::primaryKey()[0];
$this->$pk = $result['id'];
Expand All @@ -164,7 +164,7 @@ public function delete($options = [])
}

$data = array_merge($options, ['id' => $this->getOldPrimaryKey()]);
$result = $this->performScenario('delete', $data);
$result = $this->query('delete', $data);

$this->setOldAttributes(null);
$this->afterDelete();
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function updateInternal($attributes = null, $options = [])
return 0;
}

$result = $this->performScenario('update', $values, $options);
$result = $this->query('update', $values, $options);

$changedAttributes = [];
foreach ($values as $name => $value) {
Expand All @@ -207,32 +207,32 @@ protected function updateInternal($attributes = null, $options = [])
return $result === false ? false : true;
}

public function batchPerformScenario($defaultScenario, $data = [], array $options = [])
public function batchQuery($defaultScenario, $data = [], array $options = [])
{
$options['batch'] = true;

return $this->performScenario($defaultScenario, $data, $options);
return $this->query($defaultScenario, $data, $options);
}

public function performScenario($defaultScenario, $data = [], array $options = [])
public function query($defaultScenario, $data = [], array $options = [])
{
$action = $this->getScenarioAction($defaultScenario);

return static::perform($action, $data, $options);
}

public static function perform($action, $data = [], array $options = [])
{
return static::getDb()->createCommand()->perform($action, static::tableName(), $data, $options);
}

public static function batchPerform($action, $data = [], array $options = [])
{
$options['batch'] = true;

return static::perform($action, $data, $options);
}

public static function perform($action, $data = [], array $options = [])
{
return static::getDb()->createCommand()->perform($action, static::tableName(), $data, $options);
}

/**
* Converts scenario name to action.
* @param string $default default action name
Expand Down
6 changes: 3 additions & 3 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function insert($runValidation = true, $attributes = null, array $options
}

$data = $this->collectData($attributes);
$results = $this->first->batchPerformScenario('create', $data, $options);
$results = $this->first->batchQuery('create', $data, $options);
$pk = $this->first->primaryKey()[0];
foreach ($this->models as $key => $model) {
$values = &$data[$key];
Expand Down Expand Up @@ -351,7 +351,7 @@ public function update($runValidation = true, $attributes = null, array $options
}

$data = $this->collectData($attributes);
$results = $this->first->batchPerformScenario('update', $data, $options);
$results = $this->first->batchQuery('update', $data, $options);

foreach ($this->models as $key => $model) {
$changedAttributes = [];
Expand All @@ -375,7 +375,7 @@ public function delete()
}

$data = $this->collectData();
$results = $this->first->batchPerformScenario('delete', $data);
$results = $this->first->batchQuery('delete', $data);

$this->afterDelete();

Expand Down

0 comments on commit c478145

Please sign in to comment.