我正在使用 NOTORM 生成查询,在应用程序中有一种情况,用户可以选择字段、条件等,因此基本上可以提出自定义查询。这样,用户可以生成一个报告,例如“名字的人 = Jack 花费 > 800”。
我正在使用 NOTORM 生成此查询,但我想存储查询以供不使用 NOTORM 的应用程序的另一部分使用。是否有任何功能可以检索生成的查询?
这是 NOTORM 对象在生成和执行查询后的样子:
object(NotORM_Result)#55 (33) {
["single":protected]=>
bool(false)
["select":protected]=>
array(0) {
}
["conditions":protected]=>
array(7) {
[0]=>
string(9) "name = ? "
[1]=>
string(12) "surname = ? "
[2]=>
string(15) "custom_field_19"
[3]=>
string(31) "custom_field_20 BETWEEN ? AND ?"
[4]=>
string(21) "custom_field_18 <= ? "
[5]=>
string(15) "custom_field_16"
[6]=>
string(10) "email = ? "
}
["where":protected]=>
array(7) {
[0]=>
string(9) "name = ? "
[1]=>
string(12) "surname = ? "
[2]=>
string(52) "custom_field_19 IN ('Yes', 'Sent lender info', 'No')"
[3]=>
string(31) "custom_field_20 BETWEEN ? AND ?"
[4]=>
string(21) "custom_field_18 <= ? "
[5]=>
string(28) "custom_field_16 IN ('Buyer')"
[6]=>
string(10) "email = ? "
}
["parameters":protected]=>
array(6) {
[0]=>
string(1) "a"
[1]=>
string(6) "Franco"
[2]=>
int(1218146400)
[3]=>
int(1249682400)
[4]=>
string(3) "800"
[5]=>
string(1) "?"
}
["order":protected]=>
array(0) {
}
["limit":protected]=>
NULL
["offset":protected]=>
NULL
["group":protected]=>
string(0) ""
["having":protected]=>
string(0) ""
["lock":protected]=>
NULL
["union":protected]=>
array(0) {
}
["unionOrder":protected]=>
array(0) {
}
["unionLimit":protected]=>
NULL
["unionOffset":protected]=>
NULL
["data":protected]=>
NULL
["referencing":protected]=>
array(0) {
}
["aggregation":protected]=>
array(0) {
}
["accessed":protected]=>
NULL
["access":protected]=>
NULL
["keys":protected]=>
array(0) {
}
["connection":protected]=>
NULL
["driver":protected]=>
NULL
["structure":protected]=>
NULL
["cache":protected]=>
NULL
["notORM":protected]=>
object(NotORM)#3 (12) {
["connection":protected]=>
object(PDO)#2 (0) {
}
["driver":protected]=>
string(5) "mysql"
["structure":protected]=>
object(NotORM_Structure_Convention)#4 (4) {
["primary":protected]=>
string(2) "id"
["foreign":protected]=>
string(5) "%s_id"
["table":protected]=>
string(2) "%s"
["prefix":protected]=>
string(0) ""
}
["cache":protected]=>
NULL
["notORM":protected]=>
NULL
["table":protected]=>
NULL
["primary":protected]=>
NULL
["rows":protected]=>
NULL
["referenced":protected]=>
array(0) {
}
["debug":protected]=>
bool(false)
["freeze":protected]=>
bool(false)
["rowClass":protected]=>
string(10) "NotORM_Row"
}
["table":protected]=>
string(5) "users"
["primary":protected]=>
string(2) "id"
["rows":protected]=>
NULL
["referenced":protected]=>
array(0) {
}
["debug":protected]=>
bool(false)
["freeze":protected]=>
bool(false)
["rowClass":protected]=>
string(10) "NotORM_Row"
}
我可以做一些迭代'where'和'parameters'的脚本,但似乎不太优雅,特别是因为这些数组的顺序不正确(我必须做一些事情,比如用下一个项目替换每个“?”在“参数”中)...任何NOTORM函数?或者您建议的任何更优雅的方式?
这是 'where' 和 'parameters' 部分,以防你对最后一个选项有一些优雅的东西:
["where":protected]=>
array(7) {
[0]=>
string(9) "name = ? "
[1]=>
string(12) "surname = ? "
[2]=>
string(52) "custom_field_19 IN ('Yes', 'Sent lender info', 'No')"
[3]=>
string(31) "custom_field_20 BETWEEN ? AND ?"
[4]=>
string(21) "custom_field_18 <= ? "
[5]=>
string(28) "custom_field_16 IN ('Buyer')"
[6]=>
string(10) "email = ? "
}
["parameters":protected]=>
array(6) {
[0]=>
string(1) "a"
[1]=>
string(6) "Franco"
[2]=>
int(1218146400)
[3]=>
int(1249682400)
[4]=>
string(3) "800"
[5]=>
string(1) "?"
}