SQL 语句优化
程序员文章站
2024-01-19 21:10:16
...
$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']; }}
回复讨论(解决方案)
没有看到 SQL,只看到 php
推荐阅读
-
SQL 语句优化
-
linux服务器,内存512M,mysql要怎么优化?
-
sql格式化工具集合_MySQL
-
Linux基础系统优化(一)
-
浅谈开启magic_quote_gpc后的sql注入攻击与防范_MySQL
-
SQL Server(MSSQLSERVER) 请求失败或服务未及时响应,有关详细信息,请参见事件日志或其他的适用的错误日志。
-
SQL*Plus break与compute的简单用法
-
数据库高级:SQL-CREATE-TABLE语句
-
工作中常用的mysql语句分享 不用php也可以实现的效果_MySQL
-
windows 2008 r2 下面搭建 iis+sql server +php5.6 环境遇见的一些问题记录一下,r2php5.6