我正在编写一个 PHP 应用程序,其中一个功能是能够查询我们所有表中的基因交互(gene_r, genes_newL_dn, genes_newL_up, genes_oldL_up, genes_oldL_dn)
。所以我有以下PHP
功能可以一次查询所有这些数据库。
public function getAllInteractions($input){
$data = array();
$sql_list = (
"SELECT * FROM genes_r JOIN drugs_r ON drugs_r.id = genes_r.id WHERE drug_name='$input' OR gene_name='$input'",
"SELECT * FROM genes_newL_dn JOIN drugs_newL_dn ON drugs_newL_dn.id = genes_newL_dn WHERE drug_name='$input' OR gene_name='$input'",
"SELECT * FROM genes_newL_up JOIN drugs_newL_up ON drugs_newL_up.id = genes_newL_up WHERE drug_name='$input' OR gene_name='$input'",
"SELECT * FROM genes_oldL_dn JOIN drugs_oldL_dn ON drugs_oldL_dn.id = genes_oldL_dn WHERE drug_name='$input' OR gene_name='$input'",
"SELECT * FROM genes_oldL_up JOIN drugs_oldL_up ON drugs_oldL_up.id = genes_oldL_up WHERE drug_name='$input' OR gene_name='$input'"
);
foreach($sql_list as $sql){
$query = $this->db->query($sql);
// case 1 : SQL Query invalid / empty results
if(!$query || $query->num_rows() == 0) {
continue;
}
else {
$id = $query->row()->id;
$sql = "SELECT interaction from matrix_r WHERE id='$id'";
$query = $this->db->query($sql);
array_push($data, $query->row());
}
}
return $data;
}
但是,我收到以下错误:
PHP Parse error: syntax error, unexpected ',' in
/chemicalgenomics/ci/application/models/search_model.php on line 81
我不明白为什么不喜欢','。它应该是一个字符串数组。有人可以帮我吗?谢谢
PS:Line 81
是数组的第一行:"SELECT * FROM ...