|
@@ -8,40 +8,41 @@ class carModel extends Model
|
|
|
{
|
|
|
private $_car_id;
|
|
|
|
|
|
- public function car_id()
|
|
|
+ public function __construct()
|
|
|
{
|
|
|
- return $this->_car_id;
|
|
|
+ parent::__construct('car_base');
|
|
|
}
|
|
|
|
|
|
- public function addCar($base_info)
|
|
|
+ public function car_id()
|
|
|
{
|
|
|
- if(empty($base_info)) return 0;
|
|
|
-
|
|
|
- if(isset($base_info['car_name'])) {
|
|
|
- $car_name = $base_info['car_name'];
|
|
|
-
|
|
|
- if($this->hasCar_name($car_name)) return 0;
|
|
|
-
|
|
|
- $insert = $this->table('car')->insert($base_info);
|
|
|
- $this->_car_id = intval($insert);
|
|
|
- return $this->_car_id;
|
|
|
- }
|
|
|
+ return $this->_car_id;
|
|
|
}
|
|
|
|
|
|
- public function addBodyInfo($car_id, $body_info)
|
|
|
+ public function car_info(array $where)
|
|
|
{
|
|
|
- if(empty($body_info)) return 0;
|
|
|
+ if(isset($where['car_id'])) {
|
|
|
+ $this->_car_id = intval($where['car_id']);
|
|
|
+ $base_info = $this->base_info($where);
|
|
|
+ if(!empty($base_info)) {
|
|
|
+ $car_info = array_merge(
|
|
|
+ $this->base_info($where),$this->air_info($where),$this->body_info($where),$this->brake_info($where),
|
|
|
+ $this->engine_info($where),$this->gearbox_info($where),$this->glass_info($where),$this->guard_info($where),
|
|
|
+ $this->inside_info($where),$this->light_info($where),$this->media_info($where),$this->motor_info($where),
|
|
|
+ $this->oper_info($where),$this->seat_info($where),$this->secure_info($where),$this->underpan_info($where)
|
|
|
+ );
|
|
|
+ return $car_info;
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
|
|
|
- if(!$this->hasCar_id($car_id)) return 0;
|
|
|
-
|
|
|
- $data = array_merge(['car_id'=>$car_id], $body_info);
|
|
|
- $insert = $this->table('car_body')->insert($data);
|
|
|
- return $insert;
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public function hasCar_id($car_id)
|
|
|
+ public function hasCar_name($car_name)
|
|
|
{
|
|
|
- $result = $this->getby_car_id($car_id);
|
|
|
+ $result = $this->table('car_base')->getby_car_name($car_name);
|
|
|
if(!empty($result)) {
|
|
|
return true;
|
|
|
}
|
|
@@ -50,14 +51,106 @@ class carModel extends Model
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function hasCar_name($car_name)
|
|
|
+ public function air_info(array $where)
|
|
|
{
|
|
|
- $result = $this->getby_car_name($car_name);
|
|
|
- if(!empty($result)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- else {
|
|
|
- return false;
|
|
|
+ return $this->table('car_air')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function base_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_base')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function body_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_body')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function brake_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_brake')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function engine_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_engine')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function gearbox_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_gearbox')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function glass_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_glass')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function guard_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_guard')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function inside_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_inside')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function light_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_light')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function media_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_media')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function motor_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_motor')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function oper_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_oper')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function seat_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_seat')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function secure_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_secure')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function underpan_info(array $where)
|
|
|
+ {
|
|
|
+ return $this->table('car_underpan')->where($where)->find();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function addCar(array $base_info, array $body_info, array $air_info, array $brake_info,
|
|
|
+ array $engine_info, array $gearbox_info, array $glass_info, array $guard_info, array $inside_info,
|
|
|
+ array $light_info, array $media_info, array $motor_info, array $oper_info, array $seat_info,
|
|
|
+ array $secure_info, array $underpan_info)
|
|
|
+ {
|
|
|
+ if(empty($base_info)) return 0;
|
|
|
+
|
|
|
+ if(isset($base_info['car_name'])) {
|
|
|
+ $car_name = $base_info['car_name'];
|
|
|
+
|
|
|
+ if($this->hasCar_name($car_name)) return 0;
|
|
|
+
|
|
|
+ $insert = $this->table('car_base')->insert($base_info);
|
|
|
+ if($insert) {
|
|
|
+ $this->_car_id = intval($insert);
|
|
|
+ $body_info['car_id'] = $this->_car_id;
|
|
|
+ $insert_body = $this->table('car_body')->insert($body_info);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->_car_id;
|
|
|
}
|
|
|
}
|
|
|
}
|