68 lines
2.3 KiB
PHP
68 lines
2.3 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
/**
|
|
* 车型库
|
|
* Created by PhpStorm.
|
|
* User: xuxb
|
|
* Date: 2021/8/6
|
|
* Time: 11:13
|
|
*/
|
|
class Auto_cars_model extends HD_Model{
|
|
private $table_name = 'lc_auto_cars';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct($this->table_name, 'default');
|
|
}
|
|
|
|
//获取完整车辆信息
|
|
public function get_title($id){
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_attr_model');
|
|
$row = $this->get(['id'=>$id],'brand_id,s_id,v_id,cor_id,incor_id');
|
|
$b_row = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
|
|
$s_row = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
|
|
if($row){
|
|
$where = [
|
|
"id in ({$row['v_id']},{$row['cor_id']},{$row['incor_id']})" => null
|
|
];
|
|
$attr = $this->auto_attr_model->map('id','',$where,'','','','id,title');
|
|
}
|
|
$title = $b_row['name'].$s_row['name'];
|
|
$attr[$row['v_id']] && $title.= $attr[$row['v_id']][0]['title'];
|
|
$attr[$row['cor_id']] && $title.= "-".$attr[$row['cor_id']][0]['title'];
|
|
$attr[$row['incor_id']] && $title.= "-".$attr[$row['incor_id']][0]['title'];
|
|
return $title;
|
|
}
|
|
|
|
//获取车系品牌完整信息
|
|
public function select_car($where=[],$order,$page,$size,$fileds='',$count=''){
|
|
|
|
!$fileds && $fileds = "{$this->table_name}.*";
|
|
$this->db->select($fileds);
|
|
$this->db->from($this->table_name);
|
|
$this->db->join('lc_auto_brand', "lc_auto_brand.id = {$this->table_name}.brand_id");
|
|
$this->db->join('lc_auto_series', "lc_auto_series.id = {$this->table_name}.s_id");
|
|
|
|
if ($where) {
|
|
$this->db->where($where);
|
|
}
|
|
if ($count) {
|
|
return $this->db->count_all_results();
|
|
}
|
|
if ($order) {
|
|
$this->db->order_by($order);
|
|
}
|
|
if ($page) {
|
|
$offset = ($page - 1) * $page_size;
|
|
$limit = $page_size;
|
|
} else {
|
|
$offset = null;
|
|
$limit = null;
|
|
}
|
|
$this->db->limit($limit, $offset);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|