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

标签 php mysql object orm idiorm

我想显示特定日期最后插入行的字段 (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/

相关文章:

MySQL 全文关键字/短语

mysql - IF ELSE 不适用于 SQL/MySQL

javascript - 对象传播运算符在 Microsoft Edge 中抛出错误

Python 对象层次结构;引用所有者实例?

PHP写入MYSQL变量等于0

php - Laravel - 使用 HTML 表单而不是 Collective HTML/Illuminate

php - 无法为 float 金额创建 Paypal 付款

javascript - 从 AJAX 提交中拆分数组 $_FILES

php - 用php的mysql记录动态生成html表

jquery - 在 for 循环 (OOP) 中创建并命名 'n' JQuery 对象