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


PHP CommonFunctions::csv_to_array方法代码示例

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


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

示例1: up

 public function up()
 {
     //$date = date_create('2000-01-01');
     //echo date_format($date, 'Y F d H:i');
     //$dt = DateTime::createFromFormat('Y F d H:i', date_format($date, 'Y F d H:i'));
     //echo date_format($dt, 'Y-m-d H:i');
     //return;
     $this->createTable('tbl_group', array('id' => 'pk', 'name' => 'varchar(50) NOT NULL', 'description' => 'text', 'create_time' => 'datetime DEFAULT NULL', 'is_active' => 'boolean NOT NULL'), 'ENGINE=InnoDB');
     $this->createTable('tbl_event', array('id' => 'pk', 'name' => 'varchar(100) NOT NULL', 'create_time' => 'datetime DEFAULT NULL', 'start_time' => 'datetime NOT NULL', 'bet_until' => 'datetime NULL', 'status' => 'int NOT NULL', 'group_id' => 'int(11) NOT NULL'), 'ENGINE=InnoDB');
     $this->createTable('tbl_bet_option', array('id' => 'pk', 'name' => 'varchar(100) NOT NULL', 'win' => 'boolean DEFAULT False', 'rate' => 'float NOT NULL', 'event_id' => 'int(11) NOT NULL', 'bet_option_type_id' => 'int(11) NOT NULL'), 'ENGINE=InnoDB');
     $this->createTable('tbl_bet_option_type', array('id' => 'pk', 'name' => 'varchar(100) NOT NULL'), 'ENGINE=InnoDB');
     $this->createTable('tbl_user', array('id' => 'pk', 'username' => 'varchar(50) NOT NULL', 'password' => 'varchar(50) NOT NULL', 'email' => 'varchar(255) NOT NULL', 'login_attempts' => 'int(11) DEFAULT 0', 'last_login_time' => 'datetime DEFAULT NULL', 'create_time' => 'datetime DEFAULT NULL', 'update_time' => 'datetime DEFAULT NULL', 'activ_key' => "varchar(128) NOT NULL DEFAULT ''", 'group_id' => 'int(11) NOT NULL', 'points' => 'int(11) NOT NULL', 'status' => 'int NOT NULL'), 'ENGINE=InnoDB');
     $this->createTable('tbl_bet_option_user', array('id' => 'pk', 'bet_option_id' => 'int(11) NOT NULL', 'user_id' => 'int(11) NOT NULL', 'bet_points' => 'int NOT NULL'), 'ENGINE=InnoDB');
     //foreign key relationships
     //the tbl_event.group_id is a reference to tbl_group.id
     $this->addForeignKey("fk_event_group", "tbl_event", "group_id", "tbl_group", "id", "CASCADE", "CASCADE");
     //the tbl_bet_option.event_id is a reference to tbl_event.id
     $this->addForeignKey("fk_bet_option_event", "tbl_bet_option", "event_id", "tbl_event", "id", "CASCADE", "CASCADE");
     //the tbl_bet_option.bet_option_type_id is a reference to tbl_bet_option_type.id
     $this->addForeignKey("fk_bet_option_bet_option_type", "tbl_bet_option", "bet_option_type_id", "tbl_bet_option_type", "id", "CASCADE", "CASCADE");
     //the tbl_user.group_id is a reference to tbl_group.id
     $this->addForeignKey("fk_user_group", "tbl_user", "group_id", "tbl_group", "id", "CASCADE", "CASCADE");
     //the tbl_bet_option_user.bet_option_id is a reference to tbl_bet_option.id
     $this->addForeignKey("fk_bet_option_user_bet_option", "tbl_bet_option_user", "bet_option_id", "tbl_bet_option", "id", "CASCADE", "CASCADE");
     //the tbl_bet_option_user.user_id is a reference to tbl_user.id
     $this->addForeignKey("fk_bet_option_user_user", "tbl_bet_option_user", "user_id", "tbl_user", "id", "CASCADE", "CASCADE");
     // default data
     $this->insert('tbl_group', array("id" => "1", "name" => "World Cup 2014 For Everyone (Free Group)", "description" => "Group for next World Cup 2014 in Brazil", "create_time" => date('Y-m-d H:i:s'), "is_active" => true));
     $this->insert('tbl_group', array("id" => "2", "name" => "World Cup 2014 Genband (Paid Group)", "description" => "Group for next World Cup 2014 in Brazil", "create_time" => date('Y-m-d H:i:s'), "is_active" => true));
     $this->insert('tbl_user', array("id" => "1", "username" => "admin", "email" => "vanminh0910@yahoo.com", "password" => md5("admin@X"), "login_attempts" => 0, "create_time" => date('Y-m-d H:i:s'), "update_time" => date('Y-m-d H:i:s'), "group_id" => 1, "points" => 2000, "status" => 1));
     $this->insert('tbl_user', array("id" => "2", "username" => "admin2", "email" => "vanminh0910@yahoo.com", "password" => md5("admin2@X"), "login_attempts" => 0, "create_time" => date('Y-m-d H:i:s'), "update_time" => date('Y-m-d H:i:s'), "group_id" => 2, "points" => 2000, "status" => 1));
     $this->insert('tbl_user', array("id" => "3", "username" => "genband", "email" => "lttrung@tma.com.vn", "password" => md5("genband@X"), "login_attempts" => 0, "create_time" => date('Y-m-d H:i:s'), "update_time" => date('Y-m-d H:i:s'), "group_id" => 2, "points" => 2000, "status" => 1));
     //            $this->insert('tbl_user', array(
     //                "id" => "2",
     //                "username" => "test",
     //                "email" => "test@mybestbet.com",
     //                "password" => md5("test"),
     //                "login_attempts" => 0,
     //                "create_time"=>date('Y-m-d H:i:s'),
     //                "update_time"=>date('Y-m-d H:i:s'),
     //                "group_id"=>1,
     //                "points" => 1000,
     //                "status" => 1,
     //            ));
     $this->insert('tbl_bet_option_type', array("id" => "1", "name" => "Asian Rate"));
     $this->insert('tbl_bet_option_type', array("id" => "2", "name" => "European Rate"));
     //load World Cup 2014 schedule
     $schedule = CommonFunctions::csv_to_array('migrations/WC2014.csv', ',');
     print_r($schedule);
     foreach ($schedule as $match) {
         $start_date = DateTime::createFromFormat('F d, Y H:i', $match['MatchDate'] . ' ' . $match['MatchTime']);
         //print_r(date_format($start_date, 'Y-m-d H:i:s'));
         for ($i = 1; $i <= 2; $i++) {
             $this->insert('tbl_event', array("name" => $match['TeamA'] . ' - ' . $match['TeamB'], "create_time" => date('Y-m-d H:i:s'), "start_time" => date_format($start_date, 'Y-m-d H:i:s'), "bet_until" => date_format($start_date, 'Y-m-d H:i:s'), "status" => Event::STATUS_DRAFT, "group_id" => $i));
             $event_id = Yii::app()->db->getLastInsertID();
             $this->insert('tbl_bet_option', array('name' => $match["TeamA"] . ' + X', 'rate' => 2, 'event_id' => $event_id, 'bet_option_type_id' => 1));
             $this->insert('tbl_bet_option', array('name' => $match["TeamB"] . ' - X', 'rate' => 2, 'event_id' => $event_id, 'bet_option_type_id' => 1));
             $this->insert('tbl_bet_option', array('name' => $match["TeamA"] . ' win', 'rate' => 2, 'event_id' => $event_id, 'bet_option_type_id' => 2));
             $this->insert('tbl_bet_option', array('name' => 'Draw', 'rate' => 1, 'event_id' => $event_id, 'bet_option_type_id' => 2));
             $this->insert('tbl_bet_option', array('name' => $match["TeamB"] . ' win', 'rate' => 1, 'event_id' => $event_id, 'bet_option_type_id' => 2));
         }
     }
     return;
     $this->insert('tbl_event', array("id" => "1", "name" => "Germany - Brazil", "create_time" => date('Y-m-d H:i:s'), "start_time" => date('Y-m-d H:i:s'), "status" => 1, "group_id" => 1));
     $this->insert('tbl_bet_option', array('id' => '1', 'name' => 'Germany', 'rate' => 2, 'event_id' => 1, 'bet_option_type_id' => 1));
     $this->insert('tbl_bet_option', array('id' => '2', 'name' => 'Brazil', 'rate' => 2, 'event_id' => 1, 'bet_option_type_id' => 1));
     $this->insert('tbl_bet_option', array('id' => '3', 'name' => 'Germany win', 'rate' => 1.5, 'event_id' => 1, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option', array('id' => '4', 'name' => 'Draw', 'rate' => 1.75, 'event_id' => 1, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option', array('id' => '5', 'name' => 'Brazil win', 'rate' => 2.5, 'event_id' => 1, 'bet_option_type_id' => 2));
     $this->insert('tbl_event', array("id" => "2", "name" => "France - Brazil", "create_time" => date('Y-m-d H:i:s'), "start_time" => date('Y-m-d H:i:s'), "status" => 1, "group_id" => 1));
     $this->insert('tbl_bet_option', array('id' => '6', 'name' => 'France', 'rate' => 2, 'event_id' => 2, 'bet_option_type_id' => 1));
     $this->insert('tbl_bet_option', array('id' => '7', 'name' => 'Brazil', 'rate' => 2, 'event_id' => 2, 'bet_option_type_id' => 1));
     $this->insert('tbl_bet_option', array('id' => '8', 'name' => 'France win', 'rate' => 1.65, 'event_id' => 2, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option', array('id' => '9', 'name' => 'Draw', 'rate' => 1.7, 'event_id' => 2, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option', array('id' => '10', 'name' => 'Brazil win', 'rate' => 2.5, 'event_id' => 2, 'bet_option_type_id' => 2));
     $this->insert('tbl_event', array("id" => "3", "name" => "Spain - Argentina", "create_time" => date('Y-m-d H:i:s'), "start_time" => date('Y-m-d H:i:s'), "status" => 1, "group_id" => 1));
     $this->insert('tbl_bet_option', array('id' => '11', 'name' => 'Spain', 'rate' => '2', 'event_id' => '3', 'bet_option_type_id' => 1));
     $this->insert('tbl_bet_option', array('id' => '12', 'name' => 'Argentina', 'rate' => 2, 'event_id' => '3', 'bet_option_type_id' => 1));
     $this->insert('tbl_bet_option', array('id' => '13', 'name' => 'Spain win', 'rate' => 1.65, 'event_id' => 3, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option', array('id' => '14', 'name' => 'Draw', 'rate' => 1.47, 'event_id' => 3, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option', array('id' => '15', 'name' => 'Argentina win', 'rate' => 2.5, 'event_id' => 3, 'bet_option_type_id' => 2));
     $this->insert('tbl_bet_option_user', array('id' => '1', 'bet_option_id' => '1', 'user_id' => '2', 'bet_points' => '200'));
     $this->insert('tbl_bet_option_user', array('id' => '2', 'bet_option_id' => '2', 'user_id' => '2', 'bet_points' => '100'));
     $this->insert('tbl_bet_option_user', array('id' => '3', 'bet_option_id' => '3', 'user_id' => '2', 'bet_points' => '150'));
     $this->insert('tbl_bet_option_user', array('id' => '4', 'bet_option_id' => '6', 'user_id' => '2', 'bet_points' => '200'));
     $this->insert('tbl_bet_option_user', array('id' => '5', 'bet_option_id' => '8', 'user_id' => '2', 'bet_points' => '100'));
     $this->insert('tbl_bet_option_user', array('id' => '6', 'bet_option_id' => '9', 'user_id' => '2', 'bet_points' => '50'));
 }
开发者ID:vanminh0910,项目名称:shangri-la,代码行数:88,代码来源:m140422_141331_create_initial_schema.php


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