Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

97 wiersze
2.4 KiB

  1. <?php
  2. /**
  3. * 数据库表类 prod_img
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm LoginController.php
  13. * Create By 2017/07/13 11:47 $
  14. */
  15. namespace common\models;
  16. use yii\db\ActiveRecord;
  17. /**
  18. * 数据库表类 prod_img.
  19. * @property integer $id
  20. * @property integer $pro_cate_id
  21. * @property string $img_url
  22. * @property string $redirect_url
  23. * @property string $memo
  24. * @property integer $img_type
  25. * @property string $create_time
  26. */
  27. class ProdImg extends ActiveRecord
  28. {
  29. /**
  30. * @inheritdoc
  31. */
  32. public static function tableName()
  33. {
  34. return 'prod_img';
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function rules()
  40. {
  41. return [
  42. [['pro_cate_id', 'img_type'], 'integer'],
  43. [['create_time'], 'safe'],
  44. [['img_url', 'redirect_url', 'memo'], 'string', 'max' => 255],
  45. ];
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function attributeLabels()
  51. {
  52. return [
  53. 'id' => 'ID',
  54. 'pro_cate_id' => 'Pro Cate ID',
  55. 'img_url' => 'Img Url',
  56. 'redirect_url' => 'Redirect Url',
  57. 'memo' => 'Memo',
  58. 'img_type' => 'Img Type',
  59. 'create_time' => 'Create Time',
  60. ];
  61. }
  62. /**
  63. * Des:获取产品的轮播图
  64. * Name: getProdImg
  65. * @param $pro_cate_id
  66. * @return array|ActiveRecord[]
  67. * @author 倪宗锋
  68. */
  69. public function getProdImg($pro_cate_id)
  70. {
  71. $select = [
  72. 'img_url',
  73. 'img_type',
  74. 'img_type'
  75. ];
  76. $where = [
  77. 'and',
  78. ['=', 'img_type', 1],
  79. ['=', 'pro_cate_id', $pro_cate_id]
  80. ];
  81. $getList = self::find()->select($select)
  82. ->where($where)
  83. ->asArray()
  84. ->all();
  85. if (count($getList) == 0) {
  86. return [];
  87. }
  88. return $getList;
  89. }
  90. }