Bug #463
how to send basic php array to mysql select
0%
Description
I am trying to fetch a column with PHP and MySQL.
When I search about - "How to array in MySQL IN - it gets either implode or join function.
However, both giving NULL
$dsn = 'mysql:dbname=table34;host=localhost';
$conn = new PDO;
$sql = "SELECT DISTINCT FROM `node_detail`";
$parentdistinct_topicsid = $conn->query($sql)->fetchAll(PDO::FETCH_COLUMN);
$related_topics = $conn->query("SELECT `field_related_topics_target_id` FROM `taxonomy_term__field_related_topics` WHERE `entity_id` = " .
$parentdistinct_topicsid0 ." AND `field_related_topics_target_id` > 22")->fetchAll(PDO::FETCH_COLUMN);
$topicsid_array = $related_topics;
$topicsid_array[] = $parentdistinct_topicsid[0];
$ids = implode("','", $topicsid_array);
$related_articles = $conn->query("SELECT `bootstrapcard` FROM `node_detail` WHERE `parent_id` IN('" .$ids. "')")->fetchAll(PDO::FETCH_COLUMN);
$print_r($related_topics);
This is a simple SELECT stuck in unknown IN with weird implode.
Although implode does not work in my case, I do not understand the purpose of implode. What I know, implode joins the strings, and how can it work?
Updated by Richard Flaherty about 1 year ago
Thanks to this article I can learn more. Expand my knowledge and abilities. Actually the article is very real.
mypascoconnect