โดย thatsawan » 06/09/2016 2:24 pm
ได้เเล้วค่ะ
โค้ด: เลือกทั้งหมด
$sql_array = array(
'SELECT' => 'tt.topic_id',
'FROM' => array(
$this->m_topictags => 'tt'
),
'WHERE' => 'tt.tag_id = 440',
);
$where_select_topic = $this->db->sql_build_query('SELECT', $sql_array);
$sql_array = array(
'SELECT' => 'tt.topic_id',
'FROM' => array(
$this->m_topictags => 'tt'
),
'WHERE' => 'tt.tag_id = 442',
);
$where_select_topic_1 = $this->db->sql_build_query('SELECT', $sql_array);
if (!empty($tag_id_search)) {
$sql_array = array(
'SELECT' => 'tt.topic_id',
'FROM' => array(
$this->m_topictags => 'tt'
),
'WHERE' => array(),
'LEFT_JOIN' => array(),
'ORDER_BY' => array(),
'GROUP_BY' => 'tt.topic_id',
);
$sql_array['WHERE'] = 'tt.topic_id IN (' . $where_select_topic . ')';
$sql_array['WHERE'] .= ' AND tt.topic_id IN (' . $where_select_topic_1 . ')';
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$query = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($query)) {
$topic_id_search[] = $row['topic_id'];
}
}
ได้เเล้วค่ะ
[code=php] $sql_array = array(
'SELECT' => 'tt.topic_id',
'FROM' => array(
$this->m_topictags => 'tt'
),
'WHERE' => 'tt.tag_id = 440',
);
$where_select_topic = $this->db->sql_build_query('SELECT', $sql_array);
$sql_array = array(
'SELECT' => 'tt.topic_id',
'FROM' => array(
$this->m_topictags => 'tt'
),
'WHERE' => 'tt.tag_id = 442',
);
$where_select_topic_1 = $this->db->sql_build_query('SELECT', $sql_array);
if (!empty($tag_id_search)) {
$sql_array = array(
'SELECT' => 'tt.topic_id',
'FROM' => array(
$this->m_topictags => 'tt'
),
'WHERE' => array(),
'LEFT_JOIN' => array(),
'ORDER_BY' => array(),
'GROUP_BY' => 'tt.topic_id',
);
$sql_array['WHERE'] = 'tt.topic_id IN (' . $where_select_topic . ')';
$sql_array['WHERE'] .= ' AND tt.topic_id IN (' . $where_select_topic_1 . ')';
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$query = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($query)) {
$topic_id_search[] = $row['topic_id'];
}
} [/code]