当前位置: 首页>>代码示例>>PHP>>正文


PHP Selection::insert方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:ondrs,项目名称:nette-bootstrap,代码行数:28,代码来源:BaseForm.php

示例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;
 }
开发者ID:filsedla,项目名称:hyperrow,代码行数:17,代码来源:HyperSelection.php

示例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;
 }
开发者ID:soundake,项目名称:pd,代码行数:12,代码来源:EventsTerms.php

示例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;
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:45,代码来源:DbChangelog.php

示例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);
 }
开发者ID:BroukPytlik,项目名称:agility,代码行数:14,代码来源:GroupedSelection.php

示例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);
 }
开发者ID:bazo,项目名称:Tatami,代码行数:10,代码来源:GroupedSelection.php

示例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);
 }
开发者ID:soundake,项目名称:pd,代码行数:20,代码来源:Venues.php

示例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;
 }
开发者ID:soundake,项目名称:pd,代码行数:12,代码来源:Events.php

示例9: insert

 public function insert($data)
 {
     unset($data['subject_id']);
     $pd = parent::insert($data);
     return $pd;
 }
开发者ID:soundake,项目名称:pd,代码行数:6,代码来源:EventsTimes.php


注:本文中的Nette\Database\Table\Selection::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。