SQL 语句优化

WBOY
Lepaskan: 2016-06-20 12:26:42
asal
1069 orang telah melayarinya

$searchlist = array(    array("id" => 3, "id2" => 16, "flat" => 1),    array("id" => 5, "id2" => 6, "flat" => 1),    array("id" => 2, "id2" => 3, "flat" => 2),    array("id" => 9, "id2" => 1, "flat" => 2),    array("id" => 6, "id2" => 4, "flat" => 1),);$searchresult = "";foreach($searchlist as $k=>$v){    if($v['flat'] == 1){        $sql = sprintf("select insurance_entitle1 as title1 from %s_insurance where insurance_id = %d", $this->tablepre, $v['id']);        $result = $this->db->get_one($sql);        $searchresult[$k]['title1'] = isset($result['title1']) ? $result['title1'] : "";        $sql = sprintf("select insurance_encontent as content from %s_insurance_section where insurancese_section=%d order by insurancese_order", $this->tablepre, $v['id']);        $result = $this->db->get_one($sql);        $searchresult[$k]['content'] = isset($result['content']) ? $result['content'] : "";        $searchresult[$k]['flat'] = $v['flat'];        $searchresult[$k]['id'] = $v['id'];    }elseif($v['flat'] == 2){        $sql = sprintf("select insurance_entitle1 as title1 from %s_insurance where insurance_id = %d", $this->tablepre, $v['id2']);        $result = $this->db->get_one($sql);        $searchresult[$k]['title1'] = isset($result['title1']) ? $result['title1'] : "";        $sql = sprintf("select insurance_encontent as content from %s_insurance_section where insurancese_id=%d order by insurancese_order", $this->tablepre, $v['id']);        $result = $this->db->get_one($sql);        $searchresult[$k]['content'] = isset($result['content']) ? $result['content'] : "";        $searchresult[$k]['flat'] = $v['flat'];        $searchresult[$k]['id'] = $v['id'];        $searchresult[$k]['sid'] = $v['id2'];    }}
Salin selepas log masuk


回复讨论(解决方案)

没有看到 SQL,只看到 php

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!