$data[$key]['squirrel'] = $this->SquirrelModel->query("select number from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and type=1 limit 0,6");
//查询公鼠
//查询公鼠
$sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=1";
$sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=1 and type=1";
$sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=2";
$sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=2 and type=1";
$womannum = $this->Cagemodel->query($sql);
$womannum = $this->Cagemodel->query($sql);
if(!empty($womannum)){
if(!empty($womannum)){
$data[$key]['womannum'] = $womannum[0]['num'];
$data[$key]['womannum'] = $womannum[0]['num'];
@ -165,16 +166,16 @@ class Api_CageController extends Ctrl_Api{
}
}
if($val['type']==2){
if($val['type']==2){
if($squirrel['sex']==1){
if($squirrel['sex']==1){
if((int)$this->SquirrelModel->field("count(*) num")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']}")->fList()['num']==1) unset($data[$key]);
if((int)$this->SquirrelModel->field("count(*) num")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fList()['num']==1) unset($data[$key]);
}if($squirrel['sex']==2){
}if($squirrel['sex']==2){
if((int)$this->SquirrelModel->field("count(*) num")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']}")->fList()['num']==2) unset($data[$key]);
if((int)$this->SquirrelModel->field("count(*) num")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fList()['num']==2) unset($data[$key]);
}
}
}else{
}else{
//查询笼位是否有不同性别鼠
//查询笼位是否有不同性别鼠
if($squirrel['sex']==1){
if($squirrel['sex']==1){
if(!empty($this->SquirrelModel->field("*")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']}")->fRow())) unset($data[$key]);
if(!empty($this->SquirrelModel->field("*")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fRow())) unset($data[$key]);
}if($squirrel['sex']==2){
}if($squirrel['sex']==2){
if(!empty($this->SquirrelModel->field("*")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']}")->fRow())) unset($data[$key]);
if(!empty($this->SquirrelModel->field("*")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fRow())) unset($data[$key]);