PHP-MySQLi-Database-Class
PHP-MySQLi-Database-Class copied to clipboard
Why do I have to return unwanted fields?
<?php
require_once "mysqli.php";
$db = new MysqliDb($db_host, $db_user, $db_pwd, $db_database);
$query_key = $_POST["search_key"];
$static = "yes";
$result_columns = ["columns_1", "columns_2", "columns_a","columns_bbb"];
$db->Where("static", $static);
$db->orHaving("columns_1", "%$query_key%", 'LIKE');
$db->orHaving("columns_2", "%$query_key%", 'LIKE');
$db->orHaving("columns_bbb", "%$query_key%", 'LIKE');
$query = $db->get("phone_number", null, $result_columns);
echo json_encode($query);
?>
$result_columns has the field "columns_bbb" that I don't need, but I don't write "columns_bbb" to the third argument of get(), which will cause a server 500 error. Is it wrong with me?
You have used columns_bbb in $db->orHaving("columns_bbb", "%$query_key%", 'LIKE'); query. When you remove this column name in your array it will give error.