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


PHP Teacher::result_count方法代码示例

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


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

示例1: new_teacher

 /**
  * Creates new teacher from console.
  */
 public function new_teacher()
 {
     $this->load->database();
     $languages = $this->lang->get_list_of_languages();
     echo 'Create new teacher' . "\n\n";
     $name = $this->_get_cli_user_input('Teacher full name');
     $email = $this->_get_cli_user_input('Teacher e-mail');
     $password = $this->_get_cli_user_input('Teacher password');
     if (count($languages)) {
         echo 'Available languages:';
         foreach ($languages as $language_key => $language_value) {
             echo "\n" . '  (' . $language_key . ') for ' . normalize($language_value) . '';
         }
     }
     $language = $this->_get_cli_user_input("\n" . 'Select teacher language');
     $this->load->library('form_validation');
     if (!$this->form_validation->required($name) || !$this->form_validation->required($email) || !$this->form_validation->required($password) || !$this->form_validation->required($language)) {
         echo 'ERROR: Some parameter(s) is(are) missing.' . "\n";
     } elseif (!$this->form_validation->valid_email($email)) {
         echo 'ERROR: E-mail is invalid.' . "\n";
     } elseif (!$this->form_validation->is_unique($email, 'teachers.email')) {
         echo 'ERROR: E-mail must be unique.' . "\n";
     } elseif (!$this->form_validation->min_length($password, 6)) {
         echo 'ERROR: Password must have at least 6 characters.' . "\n";
     } elseif (!$this->form_validation->max_length($password, 20)) {
         echo 'ERROR: Password must not be longer than 20 characters.' . "\n";
     } elseif (!array_key_exists($language, $languages)) {
         echo 'ERROR: Desired language not found.' . "\n";
     } else {
         $teacher = new Teacher();
         $teacher->fullname = $name;
         $teacher->email = $email;
         $teacher->password = sha1($password);
         $teacher->language = $language;
         $this->db->trans_begin();
         $teacher->save();
         $teacher->get_by_email($email);
         if ($teacher->result_count() == 1) {
             $this->db->trans_commit();
             echo "\n" . 'Teacher account created!';
         } else {
             $this->db->trans_rollback();
             echo "\n" . 'Teacher account failed to be created!';
         }
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:49,代码来源:cli.php


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