"www.b.com/gaoxin",   2 => "www.c.c"/> "www.b.com/gaoxin",   2 => "www.c.c">
Home > Backend Development > PHP Tutorial > 怎的获得这样的sql

怎的获得这样的sql

WBOY
Release: 2016-06-13 10:28:59
Original
1029 people have browsed it

怎样获得这样的sql
表site_url有两个字段
id:序号
url:路径
name:名称

现有个路径数组
$pagearr = array(
  0 => "www.a.com",
  1 => "www.b.com/gaoxin",
  2 => "www.c.com/xinzhan",
)

想通过这个路径数组获得名称

$pagestr = implode(',', $pagearr);
$sql = "SELECT * FROM site_url WHERE url IN ('{$pagestr}')";

打印出来的sql为:

SELECT * FROM site_url WHERE url IN('www.a.com,www.b.com/gaoxin,www.c.com/xinzhan')

这是不对的,实际想获得的sql是

SELECT * FROM site_url WHERE url IN('www.a.com','www.b.com/gaoxin','www.c.com/xinzhan')

该怎么做才能获得这样的sql

------解决方案--------------------
$pagestr = implode("','", $pagearr);

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template