Hi All,
I have a a query that needs a sub query so in order to build it to work with MySQL I needed to convert the sub part to a string with commas. for example:
SELECT
FROM table
WHERE field NOT IN ( SELECT id FROM another table WHERE id > 10)
this doesnt work, I needed to use:
SELECT
FROM table
WHERE field NOT IN (1, 2, 6, 23)
OK, so I built this in to my classes, but instead of returning a string with 1, 2, 6, 23 its returning an array, any ideas why??
here is the chunk of code that does part of this:
function set_not_hide($date) {
$hide_sql = "
SELECT employee_id
FROM hide_dates
WHERE ( '$date' BETWEEN hide_from AND hide_to )
OR ( hide_from >= '$date' )
";
$this->tmp->db_set_recordset($hide_sql, "1");
$tmp_array = $this->tmp->db_get_recordset();
$tmp_count = $this->tmp->db_get_count();
$in = "";
$y=0;
foreach($tmp_array as $tmp_a) {
if ($y == 0) {
$in = $tmp_a;
} else {
$in = $in.", ".$tmp_a;
}
$y++;
}
$this->not_hide = $in;
}
function get_not_hide() {
return $this->not_hide;
}
as you can see its quite straightforward (external calls are not that important), instead of $this->not_hide returning a string it returns an array. Its the foreach loop that does the string build.
Please help, any suggestions very welcome.