我正在使用mysqli
库进行项目,我已经达到了需要在方法内创建SELECT
查询的程度,具体取决于发送的参数。
我正在寻找的行为类似于Android的SQLite
,您可以将列作为参数传递,将值作为下一个参数传递。
我知道我可以创建查询字符串,如果参数发送到列和值的位置,通过迭代它们然后手动将字符串连接到最终查询字符串,但我想知道是否有任何核心库可以让你做这种或任何其他方式
答案 0 :(得分:0)
//$param = array(":querycon1" => "querycon", ":querycon2" => "querycon2");
// $condition = "abc=:querycon1 AND xyz=:querycon2";
protected function setQuery($column,$condition,$param){
$this->query = "SELECT $column FROM tablename WHERE $condition";
$this->param = $param //
$this->getQuery($this->query, $this->param); // to a method that processes the query
}