gpt4 book ai didi

php - ORM 类的对象无法使用 Idiorm 转换为字符串

转载 作者:行者123 更新时间:2023-11-29 18:07:30 24 4
gpt4 key购买 nike

我想显示特定日期最后插入行的字段 (bal)。

$BALdata171201 = ORM::for_table('sys_transactions')->where('date',$data171201)->select('bal')->order_by_desc('id')->limit(1)

但我不断收到错误:

可捕获的 fatal error :ORM 类的对象无法转换为字符串

如何在字符串中进行 ORM 对象转换?

我已经阅读了该问题的数十个答案,但没有找到任何解决方案。

如果我使用 var_dump 我得到:

object(IdiormResultSet)#132 (1) {
["_results":protected]=>
array(1) {
[0]=>
object(ORM)#131 (22) {
["_connection_name":protected]=>
string(7) "default"
["_table_name":protected]=>
string(16) "sys_transactions"
["_table_alias":protected]=>
NULL
["_values":protected]=>
array(0) {
}
["_result_columns":protected]=>
array(1) {
[0]=>
string(1) "*"
}
["_using_default_result_columns":protected]=>
bool(true)
["_join_sources":protected]=>
array(0) {
}
["_distinct":protected]=>
bool(false)
["_is_raw_query":protected]=>
bool(false)
["_raw_query":protected]=>
string(0) ""
["_raw_parameters":protected]=>
array(0) {
}
["_where_conditions":protected]=>
array(0) {
}
["_limit":protected]=>
NULL
["_offset":protected]=>
NULL
["_order_by":protected]=>
array(0) {
}
["_group_by":protected]=>
array(0) {
}
["_having_conditions":protected]=>
array(0) {
}
["_data":protected]=>
array(1) {
["bal"]=>
string(7) "1354.00"
}
["_dirty_fields":protected]=>
array(0) {
}
["_expr_fields":protected]=>
array(0) {
}
["_is_new":protected]=>
bool(false)
["_instance_id_column":protected]=>
NULL
}
}
}

我已经尝试过执行 $BALdata171201string = $BALdata171201string->_data;但我得到的是空 echo 。

最佳答案

我已经解决了我的问题。

在前端我使用以下方式调用:{$BALdata171201}

现在我正在使用:

{foreach $BALdata171201 as $b01s} <b>Balanço</b></br>R$ {$b01s['bal']}{/foreach}

并且工作起来很有魅力。

关于php - ORM 类的对象无法使用 Idiorm 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47702236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com