reasonableframework
reasonableframework copied to clipboard
[system/database] Improving parse database query options
[system/database] Improving parse database query options
- setfields
// get commands
$sql = get_bind_to_sql_select("rat_commands", false, array(
"setfields" => array(
"_os" => array(
"call" => array("lower", sprintf("'%s'", addslashes($device_os)))
),
"_platform" => array(
"call" => array("instr", "_os", "platform"),
)
),
"setwheres" => array(
array("and", array("gt", "id", intval($device_jobstage))),
array("and", array("gt", "_platform", 0))
),
"setorders" => array(
array("desc", "id")
),
"setpage" => 1,
"setlimit" => 1
));
- call function in bind
// update count of term
$bind = array(
"id" => $term_id,
"count" => array(
"add" => 1
)
);
$sql = get_bind_to_sql_update("autoget_terms", $bind, array(
"setkeys" => array("id")
));
exec_db_query($sql, $bind);
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
select * from rat_commands where id > 0 and instr(lower(:device_os), platform) > 0 order by id desc limit 0, 10
It works (will updated next release):
$sql = get_bind_to_sql_select("autoget_sheets", false, array(
"setwheres" => array(
array("or", array(
array("and", array("eq", "command_id", 1)),
array("and", array("in", "col_n", array(1, 2))),
array("and", array("gt", "row_n", 3))
)),
array("or", array(
array("and", array("eq", "command_id", 4)),
array("and", array("in", "col_n", array(4, 5, 6, 7))),
array("and", array("gt", "row_n", 2))
)),
array("or", array(
array("and", array("eq", "command_id", 2)),
array("and", array("in", "col_n", array(2, 3, 4, 5))),
array("and", array("gt", "row_n", 4))
))
),
//"setpage" => 1,
//"setlimit" => 1000000
));
$rows = exec_db_fetch_all($sql, $bind);