I tried to use manual metaData for model. But when I call save method I got error Notice: Undefined index: 9 in ... Phalcon\Mvc\Model\Exception: The meta-data is invalid or is corrupt in ...
When I comment metaData in model all works good
Here is code example:
public function metaData()
{
return array(
//Every column in the mapped table
MetaData::MODELS_ATTRIBUTES => array(
'heroId', 'name', 'level', 'raceId', 'classId', 'userId', 'locationId', 'xp',
'maxHp', 'currentHp', 'maxMp', 'currentMp', 'attack', 'armor'
),
//Every column part of the primary key
MetaData::MODELS_PRIMARY_KEY => array(
'heroId'
),
//Every column that isn't part of the primary key
MetaData::MODELS_NON_PRIMARY_KEY => array(
'name', 'level', 'raceId', 'classId', 'userId', 'locationId', 'xp',
'maxHp', 'currentHp', 'maxMp', 'currentMp', 'attack', 'armor'
),
//The identity column, use boolean false if the model doesn't have
//an identity column
MetaData::MODELS_IDENTITY_COLUMN => 'heroId',
MetaData::MODELS_DATA_TYPES_NUMERIC => array(
'locationId' => true,
)
);
}
public function columnMap()
{
return array(
'heroId' => 'heroId',
'name' => 'name',
'level' => 'level',
'raceId' => 'raceId',
'classId' => 'classId',
'userId' => 'userId',
'locationId' => 'locationId',
'xp' => 'xp',
'maxHp' => 'maxHp',
'currentHp' => 'currentHp',
'maxMp' => 'maxMp',
'currentMp' => 'currentMp',
'attack' => 'attack',
'armor' => 'armor',
);
}
And table schema:
CREATE TABLE `heroes` (
`heroId` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`level` int(11) NOT NULL DEFAULT '1',
`raceId` int(11) DEFAULT NULL,
`classId` int(11) DEFAULT NULL,
`userId` int(11) DEFAULT NULL,
`locationId` int(11) DEFAULT NULL,
`xp` int(10) unsigned NOT NULL DEFAULT '0',
`maxHp` int(11) unsigned NOT NULL,
`currentHp` int(11) unsigned NOT NULL,
`maxMp` int(11) unsigned NOT NULL,
`currentMp` int(11) unsigned NOT NULL,
`attack` int(10) unsigned NOT NULL,
`armor` int(10) unsigned NOT NULL,
PRIMARY KEY (`heroId`),
UNIQUE KEY `name_UNIQUE` (`name`),
) ENGINE=InnoDB AUTO_INCREMENT=26498 DEFAULT CHARSET=utf8