"www.b.com/gaoxin",   2 => "www.c.c"/> "www.b.com/gaoxin",   2 => "www.c.c">

Home >Backend Development >PHP Tutorial >怎的获得这样的sql

怎的获得这样的sql

WBOY
WBOYOriginal
2016-06-13 10:28:591030browse

怎样获得这样的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);

Statement:
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