當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Db_Table::insert方法代碼示例

本文整理匯總了PHP中Zend_Db_Table::insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Db_Table::insert方法的具體用法?PHP Zend_Db_Table::insert怎麽用?PHP Zend_Db_Table::insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Db_Table的用法示例。


在下文中一共展示了Zend_Db_Table::insert方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: insert

 public function insert(array $data)
 {
     $this->_db = CrFramework_Db_Control::getAdapter('write');
     $this->setDefaultAdapter($this->_db);
     //logStd(get_class($this).'->createRow()', 'Write to MASTER:'.$id);
     return parent::insert($data);
 }
開發者ID:xinghao,項目名稱:shs,代碼行數:7,代碼來源:Table.php

示例2: insert

 public function insert($data)
 {
     if (empty($data['nazwa']) && empty($data['producent']) && empty($data['termin_licencji']) && empty($data['numer_seryjny'])) {
         throw new Soft_Validation_Exception('Zadne pole wymagane nie zostalo wypelnione!!!');
     }
     if (empty($data['nazwa'])) {
         throw new Soft_Validation_Exception('Nie podales nazwy oprogramowania! Pole wymagane!!!');
     }
     if (empty($data['producent'])) {
         throw new Soft_Validation_Exception('Nie podales producenta oprogramowania! Pole wymagane!!!');
     }
     if (empty($data['nr_seryjny'])) {
         throw new Soft_Validation_Exception('Nie podales nmeru seryjnego! Pole wymagane!!!');
     }
     if (empty($data['termin_licencji'])) {
         throw new Soft_Validation_Exception('Nie podales terminu licencji! Pole wymagane!!!');
     }
     if (empty($data['termin_licencji'])) {
         throw new Soft_Validation_Exception('Nie podales terminu licencji! Pole wymagane!!!');
     }
     if (!eregi('[0-9]', $data['ilosc_stanowisk'])) {
         throw new Soft_Validation_Exception('Niepoprawna liczba stanowisk!');
     }
     if (!eregi('[0-9-]', $data['termin_licencji'])) {
         throw new Soft_Validation_Exception('Niepoprawna data!');
     }
     return parent::insert($data);
 }
開發者ID:BackupTheBerlios,項目名稱:umlrecord,代碼行數:28,代碼來源:Oprogramowanie.php

示例3: save

 /**
  * Saves the properties to the database.
  * 
  * This performs an intelligent insert/update, and reloads the 
  * properties with fresh data from the table on success.
  * 
  * @return int 0 on failure, 1 on success.
  */
 public function save()
 {
     // convenience var for the primary key name
     $primary = $this->_info['primary'];
     // check the primary key value for insert/update
     if (empty($this->_data[$primary])) {
         // no primary key value, must be an insert.
         // make sure it's null.
         $this->_data[$primary] = null;
         // attempt the insert.
         $result = $this->_table->insert($this->_data);
         if (is_numeric($result)) {
             // insert worked, refresh with data from the table
             $this->_data[$primary] = $result;
             $this->_refresh();
         }
         // regardless of success return the result
         return $result;
     } else {
         // has a primary key value, update only that key.
         $where = $this->_db->quoteInto("{$primary} = ?", $this->_data[$primary]);
         // return the result of the update attempt,
         // no need to update the row object.
         $result = $this->_table->update($this->_data, $where);
         if (is_int($result)) {
             // update worked, refresh with data from the table
             $this->_refresh();
         }
     }
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:38,代碼來源:Row.php

示例4: insert

 public function insert($data)
 {
     if (!$this->ifLogin($data['login'])) {
         throw new User_Validation_Exception('Podany login istnieje juz w bazie danych! Wybierz inny.');
     }
     if (empty($data['login']) && empty($data['haslo'])) {
         throw new User_Validation_Exception('Nie podales loginu ani hasla!');
     }
     if (empty($data['login'])) {
         throw new User_Validation_Exception('Nie podales loginu!');
     }
     if (strlen($data['login']) < 5) {
         throw new User_Validation_Exception('Login musi skladac sie z co najmniej 5 znakow!');
     }
     if (empty($data['haslo'])) {
         throw new User_Validation_Exception('Nie podales hasla!');
     }
     if (strlen($data['haslo']) < 5) {
         throw new User_Validation_Exception('Haslo musi skladac sie z co najmniej 5 znakow!');
     }
     if (!eregi('^[a-zA-z]', $data['login'])) {
         throw new User_Validation_Exception('Login musi zaczynac sie od litery!');
     }
     return parent::insert($data);
 }
開發者ID:BackupTheBerlios,項目名稱:phppool,代碼行數:25,代碼來源:Uzytkownicy.php

示例5: insert

 /**
  * Inserts a new row.
  *
  * @param  array  $data  Column-value pairs.
  * @return mixed         The primary key of the row inserted.
  */
 public function insert(array $data)
 {
     $rowMaxSort = $this->fetchRow($this->select()->order('sort DESC'));
     $maxSort = $rowMaxSort ? (int) $rowMaxSort->sort + 1 : 1;
     $data['sort'] = $maxSort;
     return parent::insert($data);
 }
開發者ID:kytvi2p,項目名稱:ZettaFramework,代碼行數:13,代碼來源:Table.php

示例6: add

 /**
  * Add new setting and return ID of the setting
  */
 public function add($setting, $table)
 {
     global $logger;
     $oTable = new Zend_Db_Table($table);
     $data = array('name' => $setting->name);
     $result = $oTable->insert($data);
     $logger->log("Add setting {$table}={$setting->name}", Zend_Log::INFO);
     return $result;
 }
開發者ID:ka2er,項目名稱:mmc-flex,代碼行數:12,代碼來源:SettingsMapper.php

示例7: insert

 public function insert(array $data)
 {
     if (empty($data['created_at'])) {
         $data['created_at'] = date('Y-m-d h:i:s');
     }
     if (empty($data['updated_at'])) {
         $data['updated_at'] = date('Y-m-d h:i:s');
     }
     return parent::insert($data);
 }
開發者ID:ngroesz,項目名稱:Photoplate,代碼行數:10,代碼來源:Albums.php

示例8: createMessage

 /**
  * Create a new message in an existing thread
  *
  * @param array $data
  * @return $id
  */
 public function createMessage(array $data)
 {
     $messages_table = new Zend_Db_Table('messages');
     $data['date_created'] = date('Y-m-d H:i:s');
     $messages_table->insert($data);
     $threads_table = new Zend_Db_Table('threads');
     $thread_data = array('unread' => new Zend_Db_Expr('unread + 1'), 'deleted_from' => 0, 'deleted_to' => 0, 'last_speaker' => $data['user_from']);
     $where = array('id = ?' => $data['thread_id']);
     $threads_table->update($thread_data, $where);
 }
開發者ID:Arteaga2k,項目名稱:nolotiro,代碼行數:16,代碼來源:Message.php

示例9: insert

 public function insert(&$data)
 {
     if (empty($data['nazwa'])) {
         throw new Hamster_Validation_Exception('Podaj nazwę ankiety.');
     }
     if (strlen($data['nazwa']) < 6) {
         throw new Hamster_Validation_Exception('Nazwa ankiety musi miec conamniej 6 znaków.');
     }
     return parent::insert($data);
 }
開發者ID:BackupTheBerlios,項目名稱:phppool,代碼行數:10,代碼來源:Ankiety.php

示例10: formAction

 public function formAction()
 {
     $table = new Zend_Db_Table();
     $table->setOptions(array('name' => 'test'));
     $table->setMetadataCacheInClass(true);
     $data = array('listorder' => '11');
     $table->insert($data);
     Zend_Debug::dump($table);
     die;
 }
開發者ID:laiello,項目名稱:xinhuxi,代碼行數:10,代碼來源:IndexController.php

示例11: setup

 /**
  * (non-PHPdoc)
  * @see models/Sahara/Auth/Sahara_Auth_Session::setup()
  */
 public function setup()
 {
     $table = new Zend_Db_Table('users');
     $record = $table->fetchRow($table->select()->where('name = ?', $this->_authType->getUsername())->where('namespace = ?', $this->_config->institution));
     /* User name exists, so no need to create account. */
     if ($record) {
         return;
     }
     $table->insert(array('name' => $this->_authType->getUsername(), 'namespace' => $this->_config->institution, 'persona' => 'USER'));
 }
開發者ID:jeking3,項目名稱:web-interface,代碼行數:14,代碼來源:SaharaAccount.php

示例12: save

 /**
  * Save a new entry
  * @param  array $data
  * @return int|string
  */
 public function save(array $data)
 {
     $table = new Zend_Db_Table('users');
     $fields = $table->info(Zend_Db_Table_Abstract::COLS);
     foreach ($data as $field => $value) {
         if (!in_array($field, $fields)) {
             unset($data[$field]);
         }
     }
     return $table->insert($data);
 }
開發者ID:Arteaga2k,項目名稱:nolotiro,代碼行數:16,代碼來源:User.php

示例13: addUser

 /**
  * Register new user with given $id and $password
  * Returns true in case of success and false if user with given $id already
  * exists
  *
  * @param string $id user identity URL
  * @param string $password encoded user password
  * @return bool
  */
 public function addUser($id, $password)
 {
     // escaping not required as values are inserted as parameters
     $user = array('username' => $id, 'password' => $password, 'created' => date('Y-m-d H:i:s'), 'openid' => Zend_OpenId::absoluteURL('/openid/' . $id));
     if ($this->hasUser($id)) {
         return false;
     } else {
         $this->_usersTable->insert($user);
     }
     return true;
 }
開發者ID:heiglandreas,項目名稱:Zend-Framework-OpenID-Provider,代碼行數:20,代碼來源:Db.php

示例14: save

 /**
  * Save object in DB
  * 
  * @return HumanHelp_Model_Comment
  */
 public function save()
 {
     $table = new Zend_Db_Table('comments');
     if (isset($this->_id)) {
         // Update
         $table->update($this->_data, $table->getAdapter()->quoteInto('id = ?', $this->_id));
     } else {
         // Insert
         $table->insert($this->_data);
         $this->_id = $table->getAdapter()->lastInsertId('comments', 'id');
     }
     return $this;
 }
開發者ID:shevron,項目名稱:HumanHelp,代碼行數:18,代碼來源:Comment.php

示例15: addAction

 public function addAction()
 {
     $form = new Application_Model_ContactForm(array('action' => '/contact/add', 'method' => 'POST'));
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $contact = new Zend_Db_Table('contacts');
             $data = array('name' => $this->_request->getPost('name'), 'email' => $this->_request->getPost('email'), 'type' => $this->_request->getPost('type'));
             $contact->insert($data);
             echo "<p>Contact added!</p>";
         }
     }
     $this->view->form = $form;
 }
開發者ID:alannet,項目名稱:example,代碼行數:13,代碼來源:ContactsController.php


注:本文中的Zend_Db_Table::insert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。