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


PHP RandomGenerator::generateString方法代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     $model = new Clients();
     $account = new Accounts();
     $preference = new Preferences();
     if (isset($_POST['Clients'], $_POST['Accounts'], $_POST['Preferences'])) {
         $model->attributes = $_POST['Clients'];
         $account->attributes = $_POST['Accounts'];
         $preference->attributes = $_POST['Preferences'];
         $model->login_name = $account->login_name;
         $model->client_code = RandomGenerator::generateString(AdminGlobals::CLIENT_CODE_LENGTH);
         $model->subscription_status = "active";
         $preference->prepaid_passwd = RandomGenerator::generateString(AdminGlobals::PREPAID_PASSWD_LENGTH);
         $account->account_name = $model->client_name;
         $account->email = $model->email;
         $account->is_visible = 0;
         $valid = $model->validate();
         $valid = $account->validate() && $valid;
         $valid = $preference->validate() && $valid;
         if ($valid) {
             $transaction = Yii::app()->db->beginTransaction();
             $success = $model->save(false);
             if ($success) {
                 $account->client_id = $preference->client_id = $model->id;
             }
             $success = $success && $account->save(false);
             $success = $success && $preference->save(false);
             if ($success) {
                 $transaction->commit();
                 if (Yii::app()->request->isAjaxRequest) {
                     $this->renderPartial('view', array('model' => $this->loadModel($model->id), 'account' => $account, 'preference' => $preference), false, true);
                     Yii::app()->end();
                 }
                 $this->redirect(array('view', 'id' => $model->id));
             }
             $transaction->rollBack();
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('create', array('model' => $model, 'account' => $account, 'preference' => $preference), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'account' => $account, 'preference' => $preference));
 }
开发者ID:thehiddennepali,项目名称:Sample-Code,代码行数:44,代码来源:ClientsController.php


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