You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm TestController.php
  13. * Create By 2017/7/14 15:03 $
  14. */
  15. namespace console\controllers;
  16. use common\models\ProdComment;
  17. use yii\console\Controller;
  18. class TestController extends Controller
  19. {
  20. public function actionIndex()
  21. {
  22. $t = 10000;
  23. for ($i = 0; $i < $t; $i++) {
  24. $sql = "INSERT INTO `prod_comment` (
  25. `prod_id`,
  26. `star`,
  27. `title`,
  28. `content`,
  29. `u_name`,
  30. `u_id`,
  31. `create_time`
  32. )
  33. SELECT a.pro_cate_id,5,'行程评价','用户未评价,默认好评。',c.user_name,c.uid,FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-CEIL(RAND()*3600*24*30*6))
  34. from (
  35. SELECT pro_cate_id
  36. from prod_category
  37. WHERE delete_flag=0 and show_img is not null
  38. ORDER BY RAND()
  39. LIMIT 1) a
  40. join(
  41. SELECT user_name, uid
  42. from sh_user
  43. ORDER BY RAND()
  44. LIMIT 1
  45. ) c on 1=1
  46. ";
  47. \Yii::$app->db->createCommand($sql)->execute();
  48. }
  49. }
  50. }