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


PHP Zend_Db_Adapter_Abstract::insert方法代码示例

本文整理汇总了PHP中Zend_Db_Adapter_Abstract::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Abstract::insert方法的具体用法?PHP Zend_Db_Adapter_Abstract::insert怎么用?PHP Zend_Db_Adapter_Abstract::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Db_Adapter_Abstract的用法示例。


在下文中一共展示了Zend_Db_Adapter_Abstract::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveRel

 public function saveRel(Mage_Admin_Model_Permissions_Rules $rule)
 {
     $this->_write->beginTransaction();
     try {
         $roleId = $rule->getRoleId();
         $this->_write->delete($this->_ruleTable, "role_id = {$roleId}");
         $masterResources = Mage::getModel('admin/permissions_roles')->getResourcesList2D();
         $masterAdmin = false;
         if ($postedResources = $rule->getResources()) {
             foreach ($masterResources as $index => $resName) {
                 if (!$masterAdmin) {
                     $permission = in_array($resName, $postedResources) ? 'allow' : 'deny';
                     $this->_write->insert($this->_ruleTable, array('role_type' => 'G', 'resource_id' => trim($resName, '/'), 'privileges' => '', 'assert_id' => 0, 'role_id' => $roleId, 'permission' => $permission));
                 }
                 if ($resName == 'all' && $permission == 'allow') {
                     $masterAdmin = true;
                 }
             }
         }
         $this->_write->commit();
     } catch (Mage_Core_Exception $e) {
         throw $e;
     } catch (Exception $e) {
         $this->_write->rollBack();
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:26,代码来源:Rules.php

示例2: create

 /**
  * create new folder state
  *
  * @param Syncope_Model_IFolder $_folder
  * @return Syncope_Model_IFolder
  */
 public function create(Syncope_Model_IFolder $_folder)
 {
     $id = sha1(mt_rand() . microtime());
     $deviceId = $_folder->device_id instanceof Syncope_Model_IDevice ? $_folder->device_id->id : $_folder->device_id;
     $this->_db->insert($this->_tablePrefix . 'folder', array('id' => $id, 'device_id' => $deviceId, 'class' => $_folder->class, 'folderid' => $_folder->folderid instanceof Syncope_Model_IFolder ? $_folder->folderid->id : $_folder->folderid, 'parentid' => $_folder->parentid, 'displayname' => $_folder->displayname, 'type' => $_folder->type, 'creation_time' => $_folder->creation_time->format('Y-m-d H:i:s'), 'lastfiltertype' => $_folder->lastfiltertype));
     return $this->get($id);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:13,代码来源:Folder.php

示例3: run

 /**
  * Trigger an import run
  *
  * @return int Last import run ID
  */
 public function run()
 {
     if ($this->providesChanges() && !$this->rowsetExists()) {
         $this->storeRowset();
     }
     $this->db->insert('import_run', array('source_id' => $this->source->id, 'rowset_checksum' => $this->rowsetChecksum(), 'start_time' => date('Y-m-d H:i:s'), 'succeeded' => 'y'));
     return $this->db->lastInsertId();
 }
开发者ID:dgoeger,项目名称:icingadirector,代码行数:13,代码来源:Import.php

示例4: create

 /**
  * create new content state
  *
  * @param Syncope_Model_IContent $_state
  * @return Syncope_Model_IContent
  */
 public function create(Syncope_Model_IContent $_state)
 {
     $id = sha1(mt_rand() . microtime());
     $deviceId = $_state->device_id instanceof Syncope_Model_IDevice ? $_state->device_id->id : $_state->device_id;
     $folderId = $_state->folder_id instanceof Syncope_Model_IFolder ? $_state->folder_id->id : $_state->folder_id;
     $this->_db->insert($this->_tablePrefix . 'content', array('id' => $id, 'device_id' => $deviceId, 'folder_id' => $folderId, 'contentid' => $_state->contentid, 'creation_time' => $_state->creation_time->format('Y-m-d H:i:s'), 'creation_synckey' => $_state->creation_synckey, 'is_deleted' => isset($_state->is_deleted) ? (int) (!!$_state->is_deleted) : 0));
     return $this->get($id);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:14,代码来源:Content.php

示例5: getSchemaVersion

 /**
  * Fetch the schema version of the current database
  *
  * @return string
  */
 public final function getSchemaVersion()
 {
     if (!in_array('schema_info', $this->dbAdapter->listTables())) {
         $this->createTable('schema_info', array('primary' => false), array(array('version', 'string')));
         $this->dbAdapter->insert('schema_info', array('version' => '00000000000000'));
         return '00000000000000';
     }
     return $this->dbAdapter->fetchOne($this->dbAdapter->select()->from('schema_info', 'version')->limit(1));
 }
开发者ID:humansky,项目名称:qframe,代码行数:14,代码来源:Adapter.php

示例6: copyTreeByShadowPath

 /**
  * @param $shadowPath
  * @param $newPath
  * @param $oldPath
  * @param $newShadowPath
  * @param $oldShadowPath
  */
 public function copyTreeByShadowPath($shadowPath, $newPath, $oldPath, $newShadowPath, $oldShadowPath)
 {
     $select = $this->_db->select()->from($this->_tablePrefix . $this->_tableName, array('path' => new Zend_Db_Expr($this->_db->quoteInto($this->_db->quoteInto('REPLACE(path, ?', $oldPath) . ', ?)', $newPath)), 'shadow_path' => new Zend_Db_Expr($this->_db->quoteInto($this->_db->quoteInto('REPLACE(shadow_path, ?', $oldShadowPath) . ', ?)', $newShadowPath)), 'record_id' => 'record_id', 'creation_time' => new Zend_Db_Expr('NOW()')))->where($this->_db->quoteInto($this->_db->quoteIdentifier('shadow_path') . ' like ?', $shadowPath . '/%'));
     $stmt = $this->_db->query($select);
     $entries = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     foreach ($entries as $entry) {
         $entry['id'] = Tinebase_Record_Abstract::generateUID();
         $this->_db->insert($this->_tablePrefix . $this->_tableName, $entry);
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:17,代码来源:Sql.php

示例7: create

 /**
  * create new sync state
  *
  * @param Syncope_Model_ISyncState $_syncState
  * @return Syncope_Model_SyncState
  */
 public function create(Syncope_Model_ISyncState $_syncState, $_keepPreviousSyncState = true)
 {
     $id = sha1(mt_rand() . microtime());
     $deviceId = $_syncState->device_id instanceof Syncope_Model_IDevice ? $_syncState->device_id->id : $_syncState->device_id;
     $this->_db->insert($this->_tablePrefix . 'synckey', array('id' => $id, 'device_id' => $deviceId, 'type' => $_syncState->type instanceof Syncope_Model_IFolder ? $_syncState->type->id : $_syncState->type, 'counter' => $_syncState->counter, 'lastsync' => $_syncState->lastsync->format('Y-m-d H:i:s'), 'pendingdata' => isset($_syncState->pendingdata) && is_array($_syncState->pendingdata) ? Zend_Json::encode($_syncState->pendingdata) : null));
     $state = $this->get($id);
     if ($_keepPreviousSyncState !== true) {
         // remove all other synckeys
         $this->_deleteOtherStates($state);
     }
     return $state;
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:18,代码来源:SyncState.php

示例8: log

 /**
  * (non-PHPdoc)
  * @see Log::log()
  */
 public function log($message)
 {
     try {
         $result = $this->_db->insert($this->_table, array($this->_logFields['name'] => $this->_name, $this->_logFields['message'] => $message, $this->_logFields['date'] => date('Y-m-d H:i:s')));
         if (!$result) {
             throw new Exception('cannot save log to db ');
         }
         return true;
     } catch (Exception $e) {
         $this->_lastError = $e->getMessage();
         return false;
     }
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:17,代码来源:Db.php

示例9: logRespondentCommunication

 /**
  * Log the communication for the respondent.
  */
 protected function logRespondentCommunication()
 {
     $currentUserId = $this->loader->getCurrentUser()->getUserId();
     $changeDate = new \MUtil_Db_Expr_CurrentTimestamp();
     $logData['grco_id_to'] = $this->respondent->getId();
     if (!is_int($this->by)) {
         $this->by = 0;
     }
     $logData['grco_id_by'] = $this->by;
     $logData['grco_organization'] = $this->organizationId;
     $logData['grco_id_token'] = $this->token->getTokenId();
     $logData['grco_method'] = 'email';
     $logData['grco_topic'] = substr($this->applyFields($this->subject), 0, 120);
     $to = array();
     foreach ($this->to as $name => $address) {
         $to[] = $name . '<' . $address . '>';
     }
     $logData['grco_address'] = substr(join(',', $to), 0, 120);
     $logData['grco_sender'] = substr($this->from, 0, 120);
     $logData['grco_id_message'] = $this->templateId ? $this->templateId : null;
     $logData['grco_changed'] = $changeDate;
     $logData['grco_changed_by'] = $this->by;
     $logData['grco_created'] = $changeDate;
     $logData['grco_created_by'] = $this->by;
     $this->db->insert('gems__log_respondent_communications', $logData);
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:29,代码来源:TokenMailer.php

示例10: getAction

 /**
  *
  * @param string $action
  * @return array
  */
 protected function getAction($action)
 {
     if (array_key_exists($action, $this->_actions)) {
         return $this->_actions[$action];
     }
     // Check if a refresh from the db fixes the problem
     $this->_actions = $this->_getActionsDb();
     if (array_key_exists($action, $this->_actions)) {
         return $this->_actions[$action];
     }
     $values['gls_name'] = $action;
     $values['gls_when_no_user'] = 0;
     $values['gls_on_action'] = 0;
     $values['gls_on_post'] = 0;
     // preg_match('/(create|edit)/', $action);
     $values['gls_on_change'] = preg_match('/(create|edit|delete|deactivate|reactivate)/', $action);
     $values['gls_changed'] = $values['gls_created'] = new \MUtil_Db_Expr_CurrentTimestamp();
     $values['gls_changed_by'] = $values['gls_created_by'] = \Gems_User_UserLoader::SYSTEM_USER_ID;
     try {
         $this->_db->insert('gems__log_setup', $values);
         $this->_actions = $this->_getActionsDb();
         if (array_key_exists($action, $this->_actions)) {
             return $this->_actions[$action];
         }
     } catch (\Exception $exc) {
         $this->_warn();
     }
     return array('gls_id_action' => 0, 'gls_when_no_user' => 0, 'gls_on_action' => 0, 'gls_on_post' => 0, 'gls_on_change' => 0);
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:34,代码来源:AccessLog.php

示例11: save

 /**
  * save data
  * @param string $key
  * @param int $language_id
  * @param string $val
  * @return boolean
  */
 public function save($key, $language_id, $val, $section = "", $import = false, $newKey = "")
 {
     $data = array('key' => $newKey == "" ? $key : $newKey, 'language_id' => $language_id, 'value' => $val, 'section' => $section);
     $selectTranslate = $this->_dbTable->select()->where('`language_id` = ?', $language_id)->where('`key` = ?', $data['key']);
     if ($section != "" && !$import) {
         $data['section'] = $section;
     }
     if ($section != "" && $import) {
         $selectTranslate->where('`section` = ?', $section);
     }
     $rowTranslate = $selectTranslate->query()->fetchObject();
     // ->toArray()
     if (is_object($rowTranslate)) {
         $res = $this->_dbTable->update($data, array('id = ?' => $rowTranslate->id));
         if (!$import) {
             $this->cacheCleanTranslation();
         }
         return $res == 1;
     } else {
         $res = $this->_dbTable->insert($data);
         if (!$import) {
             $this->cacheCleanTranslation();
         }
         return $res > 0;
     }
 }
开发者ID:bokultis,项目名称:kardiomedika,代码行数:33,代码来源:TranslationMapper.php

示例12: aggregate

 public function aggregate($object)
 {
     if (!$object->getEntityPkValue() && $object->getId()) {
         $object->load($object->getReviewId());
     }
     $ratingModel = Mage::getModel('rating/rating');
     $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false);
     $nonDelete = array();
     foreach ($ratingSummaries as $ratingSummaryObject) {
         if ($ratingSummaryObject->getCount()) {
             $ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount());
         } else {
             $ratingSummary = $ratingSummaryObject->getSum();
         }
         $reviewsCount = $this->getTotalReviews($object->getEntityPkValue(), true, $ratingSummaryObject->getStoreId());
         $select = $this->_read->select();
         $select->from($this->_aggregateTable)->where("{$this->_aggregateTable}.entity_pk_value = ?", $object->getEntityPkValue())->where("{$this->_aggregateTable}.entity_type = ?", $object->getEntityId())->where("{$this->_aggregateTable}.store_id = ?", $ratingSummaryObject->getStoreId());
         $oldData = $this->_read->fetchRow($select);
         $data = new Varien_Object();
         $data->setReviewsCount($reviewsCount)->setEntityPkValue($object->getEntityPkValue())->setEntityType($object->getEntityId())->setRatingSummary($ratingSummary > 0 ? $ratingSummary : 0)->setStoreId($ratingSummaryObject->getStoreId());
         $this->_write->beginTransaction();
         try {
             if ($oldData['primary_id'] > 0) {
                 $condition = $this->_write->quoteInto("{$this->_aggregateTable}.primary_id = ?", $oldData['primary_id']);
                 $this->_write->update($this->_aggregateTable, $data->getData(), $condition);
             } else {
                 $this->_write->insert($this->_aggregateTable, $data->getData());
             }
             $this->_write->commit();
         } catch (Exception $e) {
             $this->_write->rollBack();
         }
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:34,代码来源:Review.php

示例13: isValid

 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @return boolean
  * @throws \Zend_Valid_Exception If validation of $value is impossible
  */
 public function isValid($value)
 {
     if ($throttleSettings = $this->project->getAskThrottleSettings()) {
         // Prune the database for (very) old attempts
         $where = $this->db->quoteInto('gta_datetime < DATE_SUB(NOW(), INTERVAL ? second)', $throttleSettings['period'] * 20);
         $this->db->delete('gems__token_attempts', $where);
         // Retrieve the number of failed attempts that occurred within the specified window
         $select = $this->db->select();
         $select->from('gems__token_attempts', array(new \Zend_Db_Expr('COUNT(*) AS attempts'), new \Zend_Db_Expr('UNIX_TIMESTAMP(MAX(gta_datetime)) - UNIX_TIMESTAMP() AS last')))->where('gta_datetime > DATE_SUB(NOW(), INTERVAL ? second)', $throttleSettings['period']);
         $attemptData = $this->db->fetchRow($select);
         $remainingDelay = $attemptData['last'] + $throttleSettings['delay'];
         // \MUtil_Echo::track($throttleSettings, $attemptData, $remainingDelay);
         if ($attemptData['attempts'] > $throttleSettings['threshold'] && $remainingDelay > 0) {
             $this->logger->log("Possible token brute force attack, throttling for {$remainingDelay} seconds", \Zend_Log::ERR);
             $this->_messages = $this->translate->_('The server is currently busy, please wait a while and try again.');
             return false;
         }
     }
     // The pure token check
     if ($this->isValidToken($value)) {
         return true;
     }
     $max_length = $this->tracker->getTokenLibrary()->getLength();
     $this->db->insert('gems__token_attempts', array('gta_id_token' => substr($value, 0, $max_length), 'gta_ip_address' => $this->getRequest()->getClientIp()));
     return false;
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:37,代码来源:TokenValidator.php

示例14: store

 protected function store()
 {
     $fileTable = IcingaConfigFile::$table;
     $fileKey = IcingaConfigFile::$keyName;
     $this->db->beginTransaction();
     try {
         $existingQuery = $this->db->select()->from($fileTable, 'checksum')->where('checksum IN (?)', array_map(array($this, 'dbBin'), $this->getFilesChecksums()));
         $existing = $this->db->fetchCol($existingQuery);
         foreach ($existing as $key => $val) {
             if (is_resource($val)) {
                 $existing[$key] = stream_get_contents($val);
             }
         }
         $missing = array_diff($this->getFilesChecksums(), $existing);
         /** @var IcingaConfigFile $file */
         foreach ($this->files as $name => $file) {
             $checksum = $file->getChecksum();
             if (!in_array($checksum, $missing)) {
                 continue;
             }
             $this->db->insert($fileTable, array($fileKey => $this->dbBin($checksum), 'content' => $file->getContent()));
         }
         $this->db->insert(self::$table, array('duration' => $this->generationTime, 'last_activity_checksum' => $this->dbBin($this->getLastActivityChecksum()), 'checksum' => $this->dbBin($this->getChecksum())));
         /** @var IcingaConfigFile $file */
         foreach ($this->files as $name => $file) {
             $this->db->insert('director_generated_config_file', array('config_checksum' => $this->dbBin($this->getChecksum()), 'file_checksum' => $this->dbBin($file->getChecksum()), 'file_path' => $name));
         }
         $this->db->commit();
     } catch (Exception $e) {
         $this->db->rollBack();
         throw $e;
         var_dump($e->getMessage());
     }
     return $this;
 }
开发者ID:dgoeger,项目名称:icingadirector,代码行数:35,代码来源:IcingaConfig.php

示例15: addHtmlToIndex

 /**
  * adds a HTML page to lucene index and mysql table for search result sumaries
  * @param  string $html
  * @param  string $url
  * @param  string $language
  * @return void
  */
 protected function addHtmlToIndex($html, $url, $language, $encoding, $host)
 {
     //$this->checkAndPrepareIndex();
     try {
         $content = $this->getPlainTextFromHtml($html);
         $this->db->insert("plugin_searchphp_contents_temp", array("id" => md5($url), "uri" => $url, "host" => $host, "content" => $content, "html" => $html));
         $doc = Zend_Search_Lucene_Document_Html::loadHTML($html, false, "utf-8");
         //add h1 to index
         $headlines = array();
         preg_match_all('@(<h1[^>]*?>[ \\t\\n\\r\\f]*(.*?)[ \\t\\n\\r\\f]*' . '</h1>)@si', $html, $headlines);
         if (is_array($headlines[2])) {
             $h1 = "";
             foreach ($headlines[2] as $headline) {
                 $h1 .= $headline . " ";
             }
             //logger::log($h1);
             //logger::log($encoding);
             $h1 = strip_tags($h1);
             $field = Zend_Search_Lucene_Field::Text('h1', $h1, $encoding);
             $field->boost = 10;
             $doc->addField($field);
         }
         $doc->addField(Zend_Search_Lucene_Field::Keyword('charset', $encoding));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('lang', $language));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('url', $url));
         $serialized = serialize($doc);
         $this->db->insert("plugin_searchphp_indexer_todo", array("content" => $serialized));
         //$this->index->addDocument($doc);
     } catch (Exception $e) {
         logger::log($e->getMessage(), Zend_Log::ERR);
     }
 }
开发者ID:weblizards-gmbh,项目名称:search-php,代码行数:39,代码来源:Crawler.php


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