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


PHP Zend_Db_Table::createRow方法代码示例

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


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

示例1: createAction

 public function createAction()
 {
     $data = $this->_getJsonData('data');
     if (!is_array($data)) {
         // if post one record
         $data = array($data);
     }
     $returnData = array();
     foreach ($data as $record) {
         $row = $this->_table->createRow();
         $this->_onRowCreate($row, $record);
         $row->save();
         $returnData[] = $row->toArray();
     }
     $this->view->data = $returnData;
 }
开发者ID:kandy,项目名称:system,代码行数:16,代码来源:TableEditor.php

示例2: addSite

 /**
  * Stores information about trusted/untrusted site for given user
  *
  * @param string $id user identity URL
  * @param string $site site URL
  * @param mixed $trusted trust data from extensions or just a boolean value
  * @return bool
  */
 public function addSite($id, $site, $trusted)
 {
     if (is_null($trusted)) {
         $this->_sitesTable->select()->where('site = ?', $site);
         $this->_sitesTable->delete($where);
         return true;
     }
     $row = $this->_sitesTable->createRow();
     $row->openid = $id;
     $row->site = $site;
     $row->time = date('Y-m-d H:i:s O');
     $row->trusted = serialize($trusted);
     $row->save();
     return true;
 }
开发者ID:heiglandreas,项目名称:Zend-Framework-OpenID-Provider,代码行数:23,代码来源:Db.php

示例3: _createSuperUser

 /**
  * Create super user for fresh toaster
  * @param array $data
  */
 private function _createSuperUser($data)
 {
     $db = Zend_Db::factory(new Zend_Config($this->_session->dbinfo));
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $user = array('email' => $data['adminEmail'], 'password' => md5($data['adminPassword']), 'role_id' => 'superadmin', 'full_name' => $data['adminName'], 'reg_date' => date('Y-m-d h:i:s'));
     $userTable = new Zend_Db_Table('user');
     $user = $userTable->createRow($user);
     if (!$user->save()) {
         error_log('Cannot create superadmin');
         return false;
     } else {
         //saving superadmin email to 'config' table
         $settingsTable = new Zend_Db_Table('config');
         $rowset = $settingsTable->find('adminEmail');
         if (null === ($email = $rowset->current())) {
             $email = $settingsTable->createRow();
             $email->name = 'adminEmail';
         }
         $email->value = $user['email'];
         if (!$email->save()) {
             error_log('Cannot save adminEmail to config table.');
         }
         if (isset($data['sambaToken']) && !empty($data['sambaToken'])) {
             $settingsTable->insert(array('name' => 'sambaToken', 'value' => $data['sambaToken']));
         }
     }
     return true;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:32,代码来源:IndexController.php

示例4: testTableAndIdentityWithVeryLongName

 /**
  * @group ZF-5674
  */
 public function testTableAndIdentityWithVeryLongName()
 {
     Zend_Db_Table::setDefaultAdapter($this->_db);
     // create test table using no identifier quoting
     $this->_util->createTable('thisisaveryverylongtablename', array('thisisalongtablenameidentity' => 'IDENTITY', 'stuff' => 'VARCHAR(32)'));
     $tableName = $this->_util->getTableName('thisisaveryverylongtablename');
     $table = new Zend_Db_Table('thisisaveryverylongtablename');
     $row = $table->createRow($this->_getRowForTableAndIdentityWithVeryLongName());
     $row->save();
     $rowset = $table->find(1);
     $this->assertEquals(1, count($rowset));
     $this->_util->dropTable('thisisaveryverylongtablename');
 }
开发者ID:baofeng-beijing,项目名称:zf1.11.x,代码行数:16,代码来源:TestCommon.php

示例5: accountAction

 public function accountAction()
 {
     // Leave if not ready
     if (empty($this->_session->mysql)) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'db-info'));
     }
     $this->view->form = $form = new Install_Form_Account();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Check passwords match
     $values = $form->getValues();
     if ($values['password'] != $values['password_conf']) {
         $form->addError('Passwords must match.');
         return;
     }
     // Create account
     // Connect again
     try {
         $config = $this->dbFormToConfig($this->_session->mysql);
         // Connect!
         $adapter = Zend_Db::factory($config['adapter'], $config['params']);
         $adapter->getServerVersion();
     } catch (Exception $e) {
         $form->addError('Adapter Error: ' . $e->getMessage());
         //$this->view->code = 1;
         //$this->view->error = 'Adapter Error: ' . $e->getMessage();
         return;
     }
     // attempt to disable strict mode
     try {
         $adapter->query("SET SQL_MODE = ''");
     } catch (Exception $e) {
     }
     try {
         // Preprocess
         $settingsTable = new Zend_Db_Table(array('db' => $adapter, 'name' => 'engine4_core_settings'));
         $usersTable = new Zend_Db_Table(array('db' => $adapter, 'name' => 'engine4_users'));
         $levelTable = new Zend_Db_Table(array('db' => $adapter, 'name' => 'engine4_authorization_levels'));
         // Get static salt
         $staticSalt = $settingsTable->find('core.secret')->current();
         if (is_object($staticSalt)) {
             $staticSalt = $staticSalt->value;
         } else {
             if (!is_string($staticSalt)) {
                 $staticSalt = '';
             }
         }
         // Get superadmin level
         $superAdminLevel = $levelTable->fetchRow($levelTable->select()->where('flag = ?', 'superadmin'));
         if (is_object($superAdminLevel)) {
             $superAdminLevel = $superAdminLevel->level_id;
         } else {
             $superAdminLevel = 1;
         }
         // Temporarily save pw
         $originalPassword = $values['password'];
         // Adjust values
         $values['salt'] = (string) rand(1000000, 9999999);
         $values['password'] = md5($staticSalt . $values['password'] . $values['salt']);
         $values['level_id'] = $superAdminLevel;
         $values['enabled'] = 1;
         $values['verified'] = 1;
         $values['creation_date'] = date('Y-m-d H:i:s');
         $values['creation_ip'] = ip2long($_SERVER['REMOTE_ADDR']);
         $values['displayname'] = $values['username'];
         // Try to write info to config/auth.php
         if (!$this->_writeAuthToFile($values['email'], 'seiran', $originalPassword)) {
             throw new Exception('Unable to write Auth to File');
         }
         // Insert
         $row = $usersTable->createRow();
         $row->setFromArray($values);
         $row->save();
         // First Signup Increment
         // Engine_Api::_()->getDbtable('statistics', 'core')->increment('user.creations');
         // Validate password
         if ($row->password != md5($staticSalt . $originalPassword . $row->salt)) {
             throw new Engine_Exception('Error creating password');
         }
         // Log the user into the intaller
         $auth = Zend_Registry::get('Zend_Auth');
         $auth->getStorage()->write($row->user_id);
         // Try to log the user into socialengine
         // Note: nasty hack
         try {
             $mainSessionName = 'PHPSESSID';
             if (empty($_COOKIE[$mainSessionName])) {
                 $mainSessionId = md5(mt_rand(0, time()) . serialize($_SERVER));
                 setcookie($mainSessionName, $mainSessionId, null, dirname($this->view->baseUrl()), $_SERVER['HTTP_HOST'], false, false);
             } else {
                 $mainSessionId = $_COOKIE[$mainSessionName];
             }
             $adapter->insert('engine4_core_session', array('id' => $mainSessionId, 'modified' => time(), 'lifetime' => 86400, 'data' => 'Zend_Auth|' . serialize(array('storage' => $row->user_id))));
         } catch (Exception $e) {
             // Silence
             if (APPLICATION_ENV == 'development') {
//.........这里部分代码省略.........
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:101,代码来源:InstallController.php

示例6: saveAction

 /**
  * Action save
  *
  * @return void
  */
 public function saveAction()
 {
     $form = new Admin_Form_Course();
     $table = new Tri_Db_Table('course');
     $data = $this->_getAllParams();
     if ($form->isValid($data)) {
         if (!$form->image->receive()) {
             $this->_helper->_flashMessenger->addMessage('Image fail');
         }
         $data = $form->getValues();
         if (!$form->image->getValue()) {
             unset($data['image']);
         }
         if (!$data['responsible']) {
             unset($data['responsible']);
         }
         $data['user_id'] = Zend_Auth::getInstance()->getIdentity()->id;
         if (isset($data['id']) && $data['id']) {
             $row = $table->find($data['id'])->current();
             $row->setFromArray($data);
             $id = $row->save();
         } else {
             unset($data['id']);
             $classroom = new Zend_Db_Table('classroom');
             $row = $table->createRow($data);
             $id = $row->save();
             $responsible = null;
             if (isset($data['responsible'])) {
                 $responsible = $data['responsible'];
             }
             $data = array('course_id' => $id, 'responsible' => $responsible, 'name' => 'Open ' . $data['name'], 'begin' => date('Y-m-d'));
             $row = $classroom->createRow($data);
             $row->save();
         }
         $this->_helper->_flashMessenger->addMessage('Success');
         $this->_redirect('admin/course/form/id/' . $id);
     }
     $this->_helper->_flashMessenger->addMessage('Error');
     $this->view->form = $form;
     $this->render('form');
 }
开发者ID:ramonornela,项目名称:trilhas,代码行数:46,代码来源:CourseController.php

示例7: createRow

 public function createRow(array $data = array(), $defaultSource = null)
 {
     $this->_db = CrFramework_Db_Control::getAdapter('write');
     $this->setDefaultAdapter($this->_db);
     logStd(get_class($this) . '->createRow()', 'Write to MASTER');
     return parent::createRow($data);
 }
开发者ID:xinghao,项目名称:shs,代码行数:7,代码来源:Table.php


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