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

Model's field type issue

Hey guys!

I have a table:

CREATE TABLE `office_stats` (
...
`source` TINYINT(1) UNSIGNED NULL DEFAULT NULL
...
)

in php:

$leadRef = new OfficeStats();
...
$leadRef->source = 3;
$leadRef->save();

And catch: Exception: Parameter 'source' must be a string

Why?

Clear metadata maybe?

edited Sep '17
    class OfficeStats extends Model {

        public function getSource() {
            return 'office_stats';
        }

    }

Or where?



19.7k
Accepted
answer
edited Sep '17

Renamed source to xsource, and error has lost. Maybe source is a reserved word in Phalcon Models, because it is not exactly reserved in mysql.

Oh yea sure it's very possible it's reserved word. As i remember you can't havy any property named which has get/set in Model which getSource is a case obviously.