T
T
terehinis2015-07-08 19:52:56
PHP
terehinis, 2015-07-08 19:52:56

How to remove forced renaming of properties in a model under camelCase in phalcon?

class Unit extends \Phalcon\Mvc\Model
{
    public $ID_Unit;

    public $NameUnit;
}

When sampling from such a model, the result will be
{
      "idUnit": "1",
      "nameUnit": "кв.М"
    },

But you need not to include camelCase by default and give the result
{
      "ID_Unit": "1",
      "NameUnit": "кв.М"
    },

You can do this through map in the model, but there is no desire to prescribe them in 48 models.
PS Why exactly? Our company has long established a standard for naming columns in the database. If the table ID, then ID_NameTable
If we access it from another table (Foreign Key), then NameTable_ID will be written there, which allows you to immediately see the key fields, or relational fields.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KorsaR-ZN, 2015-07-08
@terehinis

This is how you can disable column renaming globally:

\Phalcon\Mvc\Model::setup([
    'columnRenaming' => false
]);

PS See the documentation for more details.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question