Home Object of class ORM could not be converted to string Using Idiorm
Reply: 1

Object of class ORM could not be converted to string Using Idiorm

Danilo Cunha
1#
Danilo Cunha Published in 2017-12-07 19:17:18Z

I Want to show a field (bal) from the last insert row from a spefic day.

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

But I keep getting the error:

Catchable fatal error: Object of class ORM could not be converted to string

How can I make a ORM object transform in a string?

I already have read dozens of answers for this problem but I don't find any solution.

If I use var_dump I get:

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
    }
  }
}

I Already have tried do a $BALdata171201string = $BALdata171201string->_data; But I got a empty echo.

Danilo Cunha
2#
Danilo Cunha Reply to 2017-12-07 20:42:45Z

I have solved my problem.

In front end I was calling using: {$BALdata171201}

Now I'm using:

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

And work like a charm.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.318446 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO