When you're generating queries from resultsets of other queries ...

I just hit a point in an app I am currently developing, where I found myself generating queries from the resultset of another query. Because, what can possibly go wrong, right? $selectors = array(); $query_phase2 = "SHOW KEYS FROM `".$row['table']."` WHERE Key_name = 'PRIMARY'"; $query_phase3 = "select `".$row['field']."` from `".$row['table']."` where "; if($result = $GLOBALS['dbconn']->query($query_phase2)) { while ($row = $result->fetch_assoc()) { if(array_key_exists($row['Column_name'], $data)) { $qextender = "`".$row['Column_name']."` = '".$data[$row['Column_name']]."'"; array_push($selectors,$qextender); } } $query_phase3 ....

2015-07-16 · 1 min · 121 words · Jan