We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi I have written a function to see if an id in a given table exists but it doesn't work any ideas why?
function doesExist($table,$where,$whereArray,$db) { $chk = $db->query("SELECT id FROM $table WHERE $where",$whereArray); if(count($chk)>0) { echo $chk['id']; exit(); return $chk['id']; } else { return false; } }
It always returns false :( I pass the values to it like: $table = "tablename"; $where = "field = :field"; $chkArray = ["field"=>"value"]; $chk = doesExist($table,$where,$chkArray,$db);
The text was updated successfully, but these errors were encountered:
I use this code : public function exists($table, $where = NULL) { $sql = "SELECT EXISTS(SELECT 1 FROM $table ";
if (!is_null($where)) { $sql .= " WHERE $where "; } $sql .= ' LIMIT 1)'; $row = $this->db->column($sql, null); return $row[0]; } And to call
$found = exists('tablename', 'field = value');
Sorry, something went wrong.
No branches or pull requests
Hi I have written a function to see if an id in a given table exists but it doesn't work any ideas why?
It always returns false :( I pass the values to it like:
$table = "tablename";
$where = "field = :field";
$chkArray = ["field"=>"value"];
$chk = doesExist($table,$where,$chkArray,$db);
The text was updated successfully, but these errors were encountered: