【发布时间】:2019-08-17 19:37:59
【问题描述】:
我想从以下查询创建一个表...
背景是,我制作了一个额外的表格来搜索有关每个俱乐部的详细信息,您可以在其中搜索俱乐部名称的单个详细信息,或者您可以组合俱乐部名称的部分字段,让我们说部分街道名称,但表中的某些字段可以为 NULL。所以我实现了这些 IF ELSE 和 LIKE 语句。这工作正常,但如何将这些 $query 放入表中,如 CREATE TABLE SearchedClubs AS (SELECT * FROM Clubs WHERE...)
$this->db->select('*');
$this->db->from('Clubs');
if ($clubname <> NULL) {
$this->db->like('Clubname', $clubname, 'both'); }
if ($street <> NULL) {
$this->db->like('Street', $street, 'both'); }
if ($postalcode <> NULL) {
$this->db->like('Postalcode', $postalcode, 'both'); }
if ($city <> NULL) {
$this->db->like('City', $city, 'both'); }
if ($homepage <> NULL) {
$this->db->like('Homepage', $homepage, 'both'); }
if ($email <> NULL) {
$this->db->like('Email', $email, 'both'); }
if ($telephone <> NULL) {
$this->db->like('Telephone', $telephone, 'both'); }
$query = $this->db->get();
【问题讨论】:
标签: php mysql codeigniter-3 create-table