コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>开始初始化课程数据</info>');
     $this->initServiceKernel();
     $count = $input->getArgument('count', 50);
     $this->getCourseDao()->getConnection()->beginTransaction();
     try {
         for ($i = 0; $i < $count; $i++) {
             $price = $input->getArgument('price', raund(0, 100));
             $course['title'] = '课程-' . $price . '元-' . time() . '-' . $i;
             $course['status'] = 'published';
             $course['about'] = '';
             $course['userId'] = 1;
             $course['createdTime'] = time();
             $course['teacherIds'] = '|1|';
             $course['price'] = $price;
             $course['originPrice'] = $price;
             $course = $this->getCourseDao()->addCourse($course);
             $member = array('courseId' => $course['id'], 'userId' => $course['userId'], 'role' => 'teacher', 'createdTime' => time());
             $this->getMemberDao()->addMember($member);
             unset($course);
             $output->writeln('<info>第' . ($i + 1) . '个课程添加</info>');
         }
         $this->getCourseDao()->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getCourseDao()->getConnection()->rollback();
         throw $e;
     }
     $output->writeln('<info>初始化课程数据完毕</info>');
 }
コード例 #2
0
ファイル: shifrovanie.php プロジェクト: lexasub/shifrWithPHP
function allraunds($arrayOFchisla, $n, $loe, $key, $x)
{
    //*
    $b = $arrayOFchisla;
    for ($i = 1; $i < $x; $i++) {
        $b[$i] = raund($b, $n, $loe, $key);
    }
    return $b;
}