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


PHP Model::saveAll方法代码示例

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


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

示例1: _editAction

 /**
  * Generic edit action
  *
  * Triggers the following callbacks
  *	- Crud.init
  *	- Crud.beforeSave
  *	- Crud.afterSave
  *	- Crud.beforeFind
  *	- Crud.recordNotFound
  *	- Crud.afterFind
  *	- Crud.beforeRender
  *
  * @param string $id
  * @return void
  */
 protected function _editAction($id = null)
 {
     if (empty($id)) {
         $id = $this->getIdFromRequest();
     }
     $this->_validateId($id);
     if ($this->_request->is('put')) {
         $this->trigger('beforeSave', compact('id'));
         if ($this->_model->saveAll($this->_request->data, $this->_getSaveAllOptions())) {
             $this->_setFlash('update.success');
             $subject = $this->trigger('afterSave', array('id' => $id, 'success' => true));
             return $this->_redirect($subject, array('action' => 'index'));
         } else {
             $this->_setFlash('update.error');
             $this->trigger('afterSave', array('id' => $id, 'success' => false));
         }
     } else {
         $query = array();
         $query['conditions'] = array($this->_model->escapeField() => $id);
         $findMethod = $this->_getFindMethod(null, 'first');
         $subject = $this->trigger('beforeFind', compact('query', 'findMethod'));
         $query = $subject->query;
         $this->_request->data = $this->_model->find($subject->findMethod, $query);
         if (empty($this->_request->data)) {
             $subject = $this->trigger('recordNotFound', compact('id'));
             $this->_setFlash('find.error');
             return $this->_redirect($subject, array('action' => 'index'));
         }
         $this->trigger('afterFind', compact('id'));
         // Make sure to merge any changed data in the model into the post data
         $this->_request->data = Set::merge($this->_request->data, $this->_model->data);
     }
     // Trigger a beforeRender
     $this->trigger('beforeRender');
 }
开发者ID:nodesagency,项目名称:Platform-Crud-Plugin,代码行数:50,代码来源:CrudComponent.php

示例2: salvar

 public function salvar(Model $Model, $dados)
 {
     $Model->create();
     if ($Model->saveAll($dados)) {
         return true;
     }
     return $Model->validationErrors;
 }
开发者ID:AmmonMa,项目名称:cake_extras,代码行数:8,代码来源:DAOBehavior.php

示例3: saveAll

 public function saveAll($data = null, $options = array())
 {
     $this->useDbConfig = 'master';
     $status = parent::saveAll($data, $options);
     if (!isset($_SERVER['FORCEMASTER'])) {
         $this->useDbConfig = 'default';
     }
     return $status;
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:9,代码来源:AppModel.php

示例4: resetWeights

 /**
  * This will create weights based on display field. The purpose of the method is to create
  * weights for tables that existed before this behavior was added.
  *
  * @param Object $Model
  * @return boolean success
  */
 public function resetWeights(Model $Model)
 {
     if ($this->settings[$Model->alias]['foreign_key']) {
         $temp = $Model->find('all', array('fields' => $this->settings[$Model->alias]['foreign_key'], 'group' => $this->settings[$Model->alias]['foreign_key'], 'recursive' => -1));
         $foreignKeys = Hash::extract($temp, '{n}.' . $Model->alias . '.' . $this->settings[$Model->alias]['foreign_key']);
         foreach ($foreignKeys as $fk) {
             $all = $Model->find('all', array('conditions' => array($this->settings[$Model->alias]['foreign_key'] => $fk), 'fields' => array($Model->displayField, $Model->primaryKey, $this->settings[$Model->alias]['field'], $this->settings[$Model->alias]['foreign_key']), 'order' => $Model->displayField));
             $i = 1;
             foreach ($all as $key => $one) {
                 $all[$key][$Model->alias][$this->settings[$Model->alias]['field']] = $i++;
             }
             if (!$Model->saveAll($all)) {
                 return false;
             }
         }
     } else {
         $all = $Model->find('all', array('fields' => array($Model->displayField, $Model->primaryKey, $this->settings[$Model->alias]['field']), 'order' => $Model->displayField));
         $i = 1;
         foreach ($all as $key => $one) {
             $all[$key][$Model->alias][$this->settings[$Model->alias]['field']] = $i++;
         }
         if (!$Model->saveAll($all)) {
             return false;
         }
     }
     return true;
 }
开发者ID:Demired,项目名称:CakeWX,代码行数:34,代码来源:OrderedBehavior.php

示例5: restoreVersion

 /**
  * Restore data from a version_id
  *
  * @example
  *  $this->Model->restoreVersion('50537471-ba08-44ae-a606-24e5e017215a'); //restores version id 50537471-ba08-44ae-a606-24e5e017215a
  *  $this->Model->restoreVersion('50537471-ba08-44ae-a606-24e5e017215a', false); //restores version id 50537471-ba08-44ae-a606-24e5e017215a and won't create a new version before restoring.
  *  $this->Model->restoreVersion(2, 3); //restores the second version back from most recent on Model id 3
  *  $this->Model->restoreVersion(2, 3, false); //restores the second version back from most recent on Model id 3 and doesn't create a new version before saving
  *
  * @param int $version_id or the $count_of_versions_ago
  * @param model_id of the id to reversion if version is an int.
  * @param boolean create a new version on restore. boolean true
  * @return boolean result of saveAll on model
  */
 public function restoreVersion(Model $Model, $version_id, $model_id = 0, $create_new_version = true)
 {
     if ($model_id === false) {
         $create_new_version = false;
         $model_id = 0;
     }
     $restore = false;
     if (is_numeric($version_id) && !empty($model_id)) {
         $restore = $this->IcingVersion->findVersionBack($Model->alias, $version_id, $model_id);
     } else {
         $restore = $this->IcingVersion->findById($version_id);
     }
     if (!empty($restore)) {
         $model_data = json_decode($restore['IcingVersion']['json'], true);
         if ($Model->alias == $restore['IcingVersion']['model']) {
             return $Model->saveAll($model_data, array('create_version' => $create_new_version));
         } else {
             $this->addError($Model, "Restore found was for different model. {$restore['IcingVersion']['model']} != {$Model->alias}");
         }
     } else {
         $this->addError($Model, "No restore version found for params.");
     }
     return false;
 }
开发者ID:beckye67,项目名称:Icing,代码行数:38,代码来源:VersionableBehavior.php

示例6: send_mail

 public function send_mail($locale, $status, $mailsendqueue, $mail_config, $mailsendname = '')
 {
     if (isset($status) && $status != 1) {
         $this_model = new Model(false, 'mail_send_queues');
         $this_model->deleteAll(array('flag' => '5'));
         $mail_send_queue_info = $this_model->find('all', array('limit' => '10', 'order' => 'id asc'));
         $this_model->saveAll($mailsendqueue);
         return false;
     } else {
         $this->set_appconfigs($locale);
         $this->smtpauth = isset($mail_config['mail-requires-authorization']) ? trim($mail_config['mail-requires-authorization']) : 1;
         $this->is_ssl = trim($mail_config['mail-ssl']);
         $this->is_mail_smtp = trim($mail_config['mail-service']);
         $this->smtp_port = trim($mail_config['mail-port']);
         $this->smtpHostNames = trim($mail_config['mail-smtp']);
         $this->smtpUserName = trim($mail_config['mail-account']);
         $this->smtpPassword = trim($mail_config['mail-password']);
         $this->from = $mail_config['mail-address'];
         $this_model = new Model(false, 'mail_send_histories');
         $this->sendAs = $mailsendqueue['sendas'];
         $this->fromName = $mailsendqueue['sender_name'];
         $subject = $mailsendqueue['title'];
         $this->subject = $mailsendqueue['title'];
         //eval("\$subject = \"$subject\";");
         //$this->subject="=?utf-8?B?".base64_encode($subject)."?=";
         if (is_array($mailsendqueue['receiver_email'])) {
             $to_email_and_name_arr = $mailsendqueue['receiver_email'];
             $i = 0;
             foreach ($to_email_and_name_arr as $k => $v) {
                 if (strpos($v, ';')) {
                     $to_email_and_name = explode(';', $v);
                     $to_name[$i] = $to_email_and_name[0];
                     $to_email[$i] = $to_email_and_name[1];
                     ++$i;
                 }
             }
         } else {
             $to_email_and_name = explode(';', $mailsendqueue['receiver_email']);
             $to_name[] = $to_email_and_name[0];
             $to_email[] = $to_email_and_name[1];
         }
         $mailsendqueue['receiver_email'] = json_encode($mailsendqueue['receiver_email']);
         if (is_array($mailsendqueue['cc_email'])) {
             $addcc_to_email_and_name_arr = $mailsendqueue['cc_email'];
             $i = 0;
             foreach ($addcc_to_email_and_name_arr as $k => $v) {
                 if (strpos($v, ';')) {
                     $addcc_to_email_and_name = explode(';', $v);
                     $addcc_to_name[$i] = $addcc_to_email_and_name[0];
                     //�ռ�������
                     $addcc_to_email[$i] = $addcc_to_email_and_name[1];
                     //�ռ���email
                     ++$i;
                 }
             }
         } else {
             if (trim($mailsendqueue['cc_email']) != '' && trim($mailsendqueue['cc_email']) != ';') {
                 $addcc_to_email_and_name = explode(';', $mailsendqueue['cc_email']);
                 if (trim($addcc_to_email_and_name[0]) != '' && trim($addcc_to_email_and_name[1]) != ';') {
                     $addcc_to_name[] = $addcc_to_email_and_name[0];
                     //�ռ�������
                     $addcc_to_email[] = $addcc_to_email_and_name[1];
                     //�ռ���email
                 }
             }
         }
         $mailsendqueue['cc_email'] = json_encode($mailsendqueue['cc_email']);
         if (is_array($mailsendqueue['bcc_email'])) {
             $addbcc_to_email_and_name_arr = $mailsendqueue['bcc_email'];
             $i = 0;
             foreach ($addbcc_to_email_and_name_arr as $k => $v) {
                 if (strpos($v, ';')) {
                     $addbcc_to_email_and_name = explode(';', $v);
                     $addbcc_to_name[$i] = $addbcc_to_email_and_name[0];
                     //�ռ�������
                     $addbcc_to_email[$i] = $addbcc_to_email_and_name[1];
                     //�ռ���email
                     ++$i;
                 }
             }
         } else {
             if (trim($mailsendqueue['bcc_email']) != '' && trim($mailsendqueue['bcc_email']) != ';') {
                 $addbcc_to_email_and_name = explode(';', $mailsendqueue['bcc_email']);
                 if (trim($addbcc_to_email_and_name[0]) != '' && trim($addbcc_to_email_and_name[1]) != ';') {
                     $addbcc_to_name[] = $addbcc_to_email_and_name[0];
                     //�ռ�������
                     $addbcc_to_email[] = $addbcc_to_email_and_name[1];
                     //�ռ���email
                 }
             }
         }
         $mailsendqueue['bcc_email'] = json_encode($mailsendqueue['bcc_email']);
         $this->html_body = $mailsendqueue['html_body'];
         $this->text_body = $mailsendqueue['text_body'];
         for ($i = 0; $i < count($to_email); ++$i) {
             $this->toName[$i] = trim($to_name[$i]);
             $this->to[$i] = trim($to_email[$i]);
         }
         if (isset($addcc_to_name)) {
             for ($i = 0; $i < count($addcc_to_name); ++$i) {
//.........这里部分代码省略.........
开发者ID:hobbysh,项目名称:seevia-frameworks,代码行数:101,代码来源:email.php

示例7: makeMatches

    public function makeMatches() {

        $teams = Team::find('1=1');
        $teamIdByName = Model::pluck($teams, 'teamid', 'name');

        $week = 0;
        $matches = [];

        foreach (explode("\n", file_get_contents("matches.txt")) as $line) {
            $parts = explode("VS", $line);
            if (count($parts) == 1 && substr(trim($line), 0, 2) == '--') {
                $week++;
            }
            if (count($parts) != 2) continue;

            list($name1, $name2) = $parts;
            $name1 = trim($name1);
            $name2 = trim($name2);

            $match = Match::create();
            $match->team1id = $teamIdByName[$name1];
            $match->team2id = $teamIdByName[$name2];
            $match->week = $week;
            $matches[] = $match;

            if (!$match->team1id) {
                die("Equipo desconocido: $name1");
            }
            if (!$match->team2id) {
                die("Equipo desconocido: $name2");
            }

        }

        if (count($matches) >= 1 && count($matches) != count(Match::find('1=1'))) {
            Match::truncate(true);
            Model::saveAll($matches);
            ?>Enfrentamientos actualizados.<br><?
        }
        else {
            ?>No hay cambios en los enfrentamientos.<br><?
        }

    }
开发者ID:xJakub,项目名称:LCE,代码行数:44,代码来源:Batch.php

示例8: show


//.........这里部分代码省略.........
                for ($week=1; $week<=$this->season->getWeeksCount(); $week++) {
                    for ($i=0; $i<$maxMatches; $i++) {
                        $team1id = HTMLResponse::fromPOST("week{$week}match{$i}team1id");
                        $team2id = HTMLResponse::fromPOST("week{$week}match{$i}team2id");
                        if ($team1id === null || $team2id === null) continue;

                        $team1id *= 1;
                        $team2id *= 1;

                        if ($team1id && $team2id) {
                            if (isset($matches[$week][$i])) {
                                $match = $matches[$week][$i];
                                $match->team1id = "$team1id";
                                $match->team2id = "$team2id";
                                $oldMatches[] = $match;
                            }
                            else {
                                $match = Match::create();
                                $match->result = 0;
                                $match->week = $week;
                                $match->seasonid = $this->season->seasonid;
                                $match->team1id = $team1id;
                                $match->team2id = $team2id;
                                $newMatches[] = $match;
                            }
                        }
                        else {
                            if (isset($matches[$week][$i])) {
                                $matches[$week][$i]->delete();
                            }
                        }
                    }
                }
                Model::saveAll($newMatches);
                Model::saveAll($oldMatches);

                $matches =
                    Model::groupBy(
                        Match::find('seasonid = ? order by week asc, matchid asc', [$this->season->seasonid]),
                        'week'
                    );
            }


            for ($week=1; $week<=$totalWeeks; $week++) {
                ?>
                <br>
                <table style="width:640px; margin: 0 auto; text-align: left">
                    <thead>
                    <tr>
                        <td colspan="2" style="text-align: center">Jornada Nº<?=$week?></td>
                    </tr>
                    </thead>
                    <tr>
                        <td>
                            <b>Nombre de la jornada</b>
                        </td><td>
                            <input name="week<?=$week?>name" value="<?=htmlentities($this->season->getWeekName($week))?>">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Fecha de publicación</b>
                        </td><td>
                            <input name="week<?=$week?>date" type="date" value="<?=htmlentities($this->season->getWeekDate($week))?>">
                        </td>
开发者ID:xJakub,项目名称:LCE,代码行数:67,代码来源:Admin_Season_Weeks.php

示例9: saveAll

 /**
  * Fix for non atomic queries (MyISAM  etc) and saveAll to still return just the boolean result
  * Otherwise you would have to iterate over all result values to find out if the save was successful.
  *
  * Use Configure::read('Model.atomic') to modify atomic behavior.
  * Additional options:
  *
  * - returnArray: bool
  *
  * @param mixed $data
  * @param array $options
  * @return bool Success
  */
 public function saveAll($data = null, $options = array())
 {
     if (!isset($options['atomic']) && Configure::read('Model.atomic') !== null) {
         $options['atomic'] = (bool) Configure::read('Model.atomic');
     }
     $res = parent::saveAll($data, $options);
     if (is_array($res) && empty($options['returnArray'])) {
         $res = Utility::isValidSaveAll($res);
     }
     return $res;
 }
开发者ID:Jony01,项目名称:LLD,代码行数:24,代码来源:MyModel.php

示例10: saveAll

 public function saveAll($data = null, $options = array())
 {
     $this->useMasterDb();
     return parent::saveAll($data, $options);
 }
开发者ID:nano-eight,项目名称:MysqlUtil,代码行数:5,代码来源:ReplicationBaseModel.php

示例11: _copyRecord

 /**
  * Performs the actual creation and save.
  *
  * @param object $Model Model object
  * @return mixed
  */
 protected function _copyRecord(Model $Model)
 {
     $Model->create();
     $saved = $Model->saveAll($this->record, array('validate' => false, 'deep' => true));
     if ($this->settings[$Model->alias]['masterKey']) {
         $record = $this->_updateMasterKey($Model);
         $Model->saveAll($record, array('validate' => false, 'deep' => true));
     }
     return $saved;
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:16,代码来源:CopyableBehavior.php

示例12: afterLogin

 private static function afterLogin()
 {
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
     $json = $connection->get('users/show', ['user_id' => $_SESSION['twitter-userid']]);
     $_SESSION['twitter-avatar'] = isset($json->profile_image_url) ? $json->profile_image_url : '';
     Avatar::setUsersAvatar($_SESSION['twitter-userid'], $_SESSION['twitter-username'], $_SESSION['twitter-avatar']);
     $oldAvatars = Avatar::find('1=1 order by dateline asc limit 100');
     if ($oldAvatars) {
         $oldAvatarsIds = Model::pluck($oldAvatars, 'userid');
         $json = $connection->get('users/lookup', ['user_id' => implode(',', $oldAvatarsIds)]);
         foreach ($json as $userdata) {
             $newavatars[$userdata->id_str] = $userdata->profile_image_url;
         }
         foreach ($oldAvatars as $avatar) {
             $avatar->url = $newavatars[$avatar->userid];
             $avatar->dateline = time();
         }
         Model::saveAll($oldAvatars);
     }
 }
开发者ID:xJakub,项目名称:LCE,代码行数:20,代码来源:TwitterAuth.php

示例13: __installData

 protected function __installData($basePrefix = '', $sample = false)
 {
     if (isset($this->fixtures)) {
         $Model = new Model(false, false, $this->connection);
         foreach ($this->fixtures as $type => $fixtures) {
             if ($type != 'sample' || $type == 'sample' && $sample == true) {
                 foreach ($fixtures as $model => $data) {
                     if (is_array($data) && !empty($data)) {
                         $tableName = $this->__getTableName($model);
                         $Model->tablePrefix = $this->__getTablePrefix($tableName, $basePrefix);
                         $Model->setSource($tableName);
                         $Model->saveAll($data, array('validate' => false));
                     }
                 }
             }
         }
     }
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:18,代码来源:CakeRelease.php

示例14: saveWithMeta

 /**
  * Save with meta
  *
  * @param Model $model
  * @param array $data
  * @param array $options
  * @return void
  * @deprecated Use standard Model::saveAll()
  */
 public function saveWithMeta(Model $model, $data, $options = array())
 {
     $data = $this->_prepareMeta($data);
     return $model->saveAll($data, $options);
 }
开发者ID:saydulk,项目名称:croogo,代码行数:14,代码来源:MetaBehavior.php

示例15: saveAll

 public function saveAll($data = null, $options = array())
 {
     $options['atomic'] = false;
     return parent::saveAll($data, $options);
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:5,代码来源:MyModel.php


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