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

MetaData without ID as primary key - blank page

In case when table does not have "id" as auto increment primary key and metaData() is used connection reset occurred.

Is something wrong with following definition in metaData() method?


class WebsitePluginVersion extends Model
{
    public $website_id;
    public $plugin_version_id;
    public $plugin_id;
    public $status;
    public $date_created;
    public $date_updated;

    public function initialize()
    {
        //
    }

    public function metaData()
    {
        return [
            MetaData::MODELS_ATTRIBUTES => [
                'website_id',
                'plugin_version_id',
                'plugin_id',
                'status',
                'date_created',
                'date_updated',
            ],
            MetaData::MODELS_PRIMARY_KEY => [
                'website_id',
                'plugin_version_id',
                'plugin_id',
            ],
            MetaData::MODELS_NON_PRIMARY_KEY => [
                'status',
                'date_created',
                'date_updated',
            ],
            MetaData::MODELS_NOT_NULL => [
                'website_id',
                'plugin_version_id',
                'plugin_id',
            ],
            MetaData::MODELS_DATA_TYPES => [
                'website_id' => Column::TYPE_INTEGER,
                'plugin_version_id' => Column::TYPE_BIGINTEGER,
                'plugin_id' => Column::TYPE_INTEGER,
                'status' => Column::TYPE_CHAR,
                'date_created' => Column::TYPE_DATETIME,
                'date_updated' => Column::TYPE_DATETIME,
            ],

            MetaData::MODELS_DATA_TYPES_NUMERIC => [
                'website_id' => true,
                'plugin_version_id' => true,
                'plugin_id' => true,
            ],

            MetaData::MODELS_DATA_TYPES_BIND => [
                'website_id' => Column::BIND_PARAM_INT,
                'plugin_version_id' => Column::BIND_PARAM_INT,
                'plugin_id' => Column::BIND_PARAM_INT,
                'status' => Column::BIND_PARAM_STR,
                'date_created' => Column::BIND_PARAM_STR,
                'date_updated' => Column::BIND_PARAM_STR,
            ],

            MetaData::MODELS_AUTOMATIC_DEFAULT_INSERT => [
                'date_created' => true,
                'date_updated' => true,
            ],

            MetaData::MODELS_AUTOMATIC_DEFAULT_UPDATE => [
                'date_created' => true,
                'date_updated' => true,
            ],
            MetaData::MODELS_DEFAULT_VALUES => [
            ],

            MetaData::MODELS_EMPTY_STRING_VALUES => [
            ],

        ];
    }
}

Check php/syslog. What php version yo use?



1.6k

Nothing in logs. php 7.0.4

Blank page means exception or something like this, there must be something in php log or syslog or apache/nginx logs.



1.6k

I'm not wondering why i have blank page - i know it's about some error. (actually connection reset occurs ). I'm just wondering what is wrong with meta data syntax. It seems like 'id' need to be in list of primary keys, but that makes no sense.

edited Mar '17

Just check logs. It's for 100% there. You could always run it in gdb, what os/php version you run?

Also why you define metadata anyway?



1.6k

I don't want any additional runtime cost which could be avoided. (Yes, i know metadata cache exists, but still - defining meta data should be fastest option)

Even if yes the difference compared to caching will be minimal.