lithium\test\Fixture::populate()
Populate custom records in the database.
Parameters
-
array
$record
The data of the record
-
boolean
$alter
If true, the
$record
will be altered according the alter rules.
Returns
booleanReturns true
on success false
otherwise.
Source
public function populate(array $record = [], $alter = true) {
if (!$record) {
return true;
}
$connections = $this->_classes['connections'];
$db = $connections::get($this->_connection);
$data = $alter ? $this->_alterRecord($record) : $record;
if ($this->_locked) {
$data = array_intersect_key($data, $this->_alteredFields);
}
$options = [
'type' => 'create', 'source' => $this->_source, 'data' => ['data' => $data]
];
$query = Libraries::instance(null, 'query', $options, $this->_classes);
return $db->create($query);
}