本文整理汇总了PHP中Nette\Database\Table\Selection::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Selection::insert方法的具体用法?PHP Selection::insert怎么用?PHP Selection::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Table\Selection
的用法示例。
在下文中一共展示了Selection::insert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Default form handler
*/
public function process()
{
/** @var ArrayHash $values */
$values = $this->values;
try {
$this->onBeforeProcess($this, $values);
if (isset($values->id)) {
$this->onBeforeUpdate($this, $values);
$arr = (array) $values;
unset($arr['id']);
$row = $this->selection->wherePrimary($values->id)->fetch();
$row->update($arr);
$this->onAfterUpdate($row, $this, $values);
} else {
$this->onBeforeInsert($this, $values);
$row = $this->selection->insert($values);
$this->onAfterInsert($row, $this, $values);
}
$this->onAfterProcess($row, $this, $values);
} catch (\PDOException $e) {
$this->addError($e->getMessage());
dump($e);
Debugger::log($e);
}
}
示例2: insert
/**
* Inserts row in a table
*
* @param array|\Traversable|(Selection|self) $data array($column => $value)|\Traversable|(Selection|self) for INSERT ... SELECT
* @return HyperRow|int|bool Returns HyperRow or number of affected rows for Selection or table without primary key
*/
public function insert($data)
{
if ($data instanceof self) {
$data = $data->selection;
}
$result = $this->selection->insert($data);
if ($result instanceof ActiveRow) {
return $this->factory->createRow($result, $this->selection->getName());
}
return $result;
}
示例3: insert
public function insert($data, $forceRegenerateTimes = FALSE)
{
unset($data['subject_id']);
$pd = parent::insert($data);
$id = $pd->id;
if ($forceRegenerateTimes) {
$this->generateAllTimes();
} else {
$this->generateAllTimes(20, $id);
}
return $pd;
}
示例4: importNewChangelogData
/**
* Checks if in database table changelog are some changes that
* wasnt executed
*/
public function importNewChangelogData()
{
$newChanges = false;
// check if there are some unexecuted queries in database
$changelogTable = clone $this->changelogTable;
if ($changelogTable->where('executed', 0)->count('*') > 0) {
// there are some unexecuted queries
return true;
}
// load files with database changes
foreach (Finder::findFiles('*.sql')->exclude('init.sql')->in($this->changelogPath) as $key => $file) {
// check if file was already inserted into changelog table
$filename = $file->getBasename('.sql');
$fileParts = explode('_', $filename);
if (count($fileParts) < 2) {
throw new \Nette\UnexpectedValueException('Changelog file "' . $filename . '" has unexpected form. It should be %timestamp%_%name%.sql');
}
$changelogTable = clone $this->changelogTable;
if ($changelogTable->where('file', $file->getBasename())->count('*') > 0) {
// this file content was already inserted
continue;
}
$newChanges = true;
// content of the file is not in database table, insert it
$filePathname = $file->getPathname();
$fileContent = trim(file_get_contents($filePathname));
$queries = explode(';', $fileContent);
foreach ($queries as $query) {
$query = trim($query);
if (empty($query)) {
continue;
}
$data = array('file' => $file->getBasename(), 'description' => substr($fileParts[1], 0), 'query' => $query, 'executed' => 0, 'ins_timestamp' => $fileParts[0], 'ins_dt' => new \DateTime(), 'ins_process_id' => 'DbChangelog::areNewChangelogData');
$this->changelogTable->insert($data);
}
if (empty($queries) || empty($fileContent)) {
$newChanges = false;
}
}
return $newChanges;
}
示例5: insert
public function insert($data)
{
if ($data instanceof \Traversable && !$data instanceof Selection) {
$data = iterator_to_array($data);
}
if (Nette\Utils\Validators::isList($data)) {
foreach (array_keys($data) as $key) {
$data[$key][$this->column] = $this->active;
}
} else {
$data[$this->column] = $this->active;
}
return parent::insert($data);
}
示例6: insert
public function insert($data)
{
if ($data instanceof \Traversable && !$data instanceof Selection) {
$data = iterator_to_array($data);
}
if (is_array($data)) {
$data[$this->column] = $this->active;
}
return parent::insert($data);
}
示例7: insert
public function insert($data)
{
$coords = Geolocation::getCoordsFromText($data['map_coords']);
$data['lat'] = $coords[0];
$data['lon'] = $coords[1];
$to_code = isset($data['locality_nickname']) ? $data['name'] . " " . $data['locality_nickname'] . " " . $data['locality_id'] : $data['name'] . " " . $data['locality_id'];
$data['code'] = $data['code'] != '' ? $data['code'] : \Nette\Utils\Strings::webalize($to_code);
$data['stroller'] = isset($data['stroller']) && $data['stroller'] == 1 ? 1 : 0;
$data['visible'] = isset($data['visible']) && $data['visible'] == 1 ? 1 : 0;
$data['ad_onhomepage'] = isset($data['ad_onhomepage']) && $data['ad_onhomepage'] == 1 ? 1 : 0;
$data['ad'] = isset($data['ad']) && $data['ad'] == 1 ? 1 : 0;
$data['show_in_catalogue'] = isset($data['show_in_catalogue']) && $data['show_in_catalogue'] == 1 ? 1 : 0;
$data['show_in_calendar'] = isset($data['show_in_calendar']) && $data['show_in_calendar'] == 1 ? 1 : 0;
$data['changed'] = new \Nette\DateTime();
$data['created'] = new \Nette\DateTime();
//$data['ad_shire'] = isset($data['ad_shire']) && $data['ad_shire'] == 0 ? null : $data['ad_shire'];
//$data['ad_category'] = isset($data['ad_category']) && $data['ad_category'] == 0 ? null : $data['ad_category'];
unset($data['categories']);
parent::insert($data);
}
示例8: insert
public function insert($data)
{
$data['code'] = Nette\Utils\Strings::webalize($data['subject_name'] . " " . $data['name']);
$data['changed'] = new \Nette\DateTime();
$data['created'] = new \Nette\DateTime();
$coords = Geolocation::getCoordsFromText($data['subject_gps']);
$data['lat'] = $coords[0];
$data['lon'] = $coords[1];
$data['last_edit_id'] = isset($this->context->user->id) ? $this->context->user->id : NULL;
$pd = parent::insert($data);
return $pd;
}
示例9: insert
public function insert($data)
{
unset($data['subject_id']);
$pd = parent::insert($data);
return $pd;
}