【发布时间】:2013-07-06 17:25:30
【问题描述】:
上面的问题^^^^^没有正确答案
由于该问题中接受的答案导致 MYSQL 页面将查询分开,我仍然需要 PHP 中的解决方案,并且此问题中提供的答案中的链接实际上是我需要的。
我正在尝试用 SQL 中的 where 子句创建一个有用的数组
让我们假设这些:
where a=b and b=c or d=g and (a=f or x=6)
where a=b and b='d and f' or d=g and (a=f or x=6)
where a=b and b="d and f (or just text)" or d=g and (a=f or x=6)
where "a"=b andb="Note that colum names might be quoted differently in different databases" or d=g and (a=f or x=6)
where "a"='b' andb="as well as values" or d=g and (a=f or x=6)
where "a"='b' andb="multiple levels" or d=g and (a=f or x=6 or (x=5 and v=7))
我想尝试将任何 where 子句(使用 key=value ... 也就是没有子查询)分解成有用的数组? 类似:
x= array(
array('a' => 'b' , 'b' => 'c'),
array('d' => 'g' , array(array('a' => 'f'),array('x' => '6')),
);
AND 在一个数组中或在新数组中
或任何其他格式,只是为了能够将整个查询重建为我想要的任何内容。
这里的 preg_match 足够了吗?
【问题讨论】:
-
这在家庭作业之外有什么用?
-
@Ronan Dejhero 每个人的问题在哪里?
-
SQL 解析器在这里会更有意义。
-
@Ronan Dejhero 我也在尝试这些,但还没有成功。感谢您发布这些问题。我无法发布问题,因为它已被阻止
-
我正在发布我的示例研发代码之一