像这么的查询还有别的什么方法可写吗
Release: 2016-06-13 13:07:03
Original
992 people have browsed it
像这样的查询还有别的什么方法可写吗?
PHP code
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->public function find()
{
$sql = "SELECT * FROM qsj_user_profile
RIGHT JOIN qsj_user ON qsj_user.uid = qsj_user_profile.uid";
if(!empty($_GET['email']))
{
$sql.="AND qsj_user.email=".$_GET['email'];
}
if(!empty($_GET['nickname']))
{
$sql.="AND qsj_user_profile.nickname = ".$_GET['nickname'];
}
if(!empty($_GET['province']))
{
$sql.="AND qsj_user_profile.province =".$_GET['province'];
}
if(!empty($_GET['city']))
{
$sql.="AND qsj_user_profile.city =".$_GET['city'];
}
if(!empty($_GET['dist']))
{
$sql.="AND qsj_user_profile.dist = ".$_GET['dist'];
}
if(!empty($_GET['style']))
{
$sql.="AND qsj_user_profile.style =".$_GET['style'];
}
$query = $this->db->query($sql);
return $query->result_array();
}
Copy after login
------解决方案--------------------AND前最好留一个空格。
------解决方案-------------------- 反正也不多。就这么写吧。
可以适当的改变一下数据放到数组里。
用foreach遍历。
当然也会遇到不同的问题。
这个就需要摸索和积累了
------解决方案--------------------这种写法基本上就这样了
------解决方案--------------------就这样写吧。没问题的。以后去找好的方法。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31