We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Weird Modal meta data in Model::find() and Model::findFirst()

This is the Code which iam trying in the IndexController:

echo "<pre>";
echo system("php -v");
echo system("php --ri phalcon");
echo "\n\n_____________\n\n";
echo "FindFirst method Result \n\n";
var_dump(Schools::findFirst()->toArray());
echo "_____________\n\n";
echo "Find method array object First Result\n\n";
var_dump(Schools::find()[0]->toArray());
echo "_____________\n\n";
echo "Find method array All Result\n\n";
var_dump(Schools::find()->toArray());
exit;

In Schools::find()->toArray() data type is not converted, All data type models are in string type: what am i missing please help.

But it working in Schools::findFirst()->toArray() & Schools::find()[0]->toArray()

OutPut

PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
phalcon

Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.2.2
Build Date => Aug 14 2017 21:13:10
Powered by Zephir => Version 0.9.9-868cb1f92b

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => On => On
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => On => On
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.disable_assign_setters => Off => Off
phalcon.orm.disable_assign_setters => Off => Off

_____________

FindFirst method Result 

array(9) {
  ["school_id"]=>
  int(1)
  ["school_name"]=>
  string(22) "Domestic I-Mobile Inc."
  ["school_lng"]=>
  float(77.17610168)
  ["school_lat"]=>
  float(13.31993103)
  ["school_created"]=>
  string(19) "2017-08-08 17:57:13"
  ["school_modified"]=>
  string(19) "2017-08-28 06:05:44"
  ["school_status"]=>
  bool(false)
  ["school_code"]=>
  string(3) "775"
  ["school_aided"]=>
  bool(false)
}
_____________

Find method array object First Result

array(9) {
  ["school_id"]=>
  int(1)
  ["school_name"]=>
  string(22) "Domestic I-Mobile Inc."
  ["school_lng"]=>
  float(77.17610168)
  ["school_lat"]=>
  float(13.31993103)
  ["school_created"]=>
  string(19) "2017-08-08 17:57:13"
  ["school_modified"]=>
  string(19) "2017-08-28 06:05:44"
  ["school_status"]=>
  bool(false)
  ["school_code"]=>
  string(3) "775"
  ["school_aided"]=>
  bool(false)
}
_____________

Find method array All Result

array(50) {
  [0]=>
  array(9) {
    ["school_id"]=>
    string(1) "1"
    ["school_name"]=>
    string(22) "Domestic I-Mobile Inc."
    ["school_lng"]=>
    string(11) "77.17610168"
    ["school_lat"]=>
    string(11) "13.31993103"
    ["school_created"]=>
    string(19) "2017-08-08 17:57:13"
    ["school_modified"]=>
    string(19) "2017-08-28 06:05:44"
    ["school_status"]=>
    string(1) "0"
    ["school_code"]=>
    string(3) "775"
    ["school_aided"]=>
    string(1) "0"
  }
  [1]=>
  array(9) {
    ["school_id"]=>
    string(1) "2"
    ["school_name"]=>
    string(30) "International Instruments Inc."
    ["school_lng"]=>
    string(11) "77.09378052"
    ["school_lat"]=>
    string(11) "13.31906986"
    ["school_created"]=>
    string(19) "2017-08-01 02:08:37"
    ["school_modified"]=>
    string(19) "2017-08-27 13:38:37"
    ["school_status"]=>
    string(1) "0"
    ["school_code"]=>
    string(4) "2676"
    ["school_aided"]=>
    string(1) "0"
  }
  [2]=>
  array(9) {
    ["school_id"]=>
    string(1) "3"
    ["school_name"]=>
    string(25) "Advanced Technologies Co."
    ["school_lng"]=>
    string(11) "77.09629059"
    ["school_lat"]=>
    string(11) "13.29784393"
    ["school_created"]=>
    string(19) "2017-08-06 00:13:03"
    ["school_modified"]=>
    string(19) "2017-08-27 23:31:19"
    ["school_status"]=>
    string(1) "0"
    ["school_code"]=>
    string(4) "1790"
    ["school_aided"]=>
    string(1) "0"
  }
  ......
}

Thank You

Hi @Rajesh you are right, Phalcon have a problem with this. Resultset don't call Model::toArray().

You have to make your own Resultset::toArray() calling internally Model::toArray().

Probably we have a NFR create an issue to check

Good luck