Column 'id' is not part of the column map when set 'castOnHydrate' => true #11205

Closed
lxholding opened this Issue Dec 8, 2015 · 3 comments

Projects

None yet

3 participants

@lxholding

phalcon:2.0.9

database:mysql

my code:

$model = $this->modelsManager->createBuilder()
            ->addFrom('warmup\models2\SubjectClassesList', 'l')
            ->columns('c.*')
            ->leftJoin('warmup\models2\Classes', 'l.classesid = c.id', 'c')
            ->where('l.subjectid = :subjectid: AND c.status <> :status:', ['subjectid' => $subjectid, 'status' => Classes::STATUS_DELETE])
            ->orderBy('c.utime DESC')
            ->limit($count, $start)
            ->getQuery()
            ->execute()->toArray();

when i use below setup:

\Phalcon\Mvc\Model::setup(
    [
        'castOnHydrate' => true
    ]
);

throw a error msg: "Phalcon\Mvc\Model\Exception: Column 'id' is not part of the column map"

table: subject_classes_list

CREATE TABLE `subject_classes_list` (
  `subjectid` int(10) unsigned NOT NULL COMMENT '课程专题id',
  `classesid` int(10) unsigned NOT NULL COMMENT '课程id',
  PRIMARY KEY (`subjectid`,`classesid`),
  KEY `index2` (`classesid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

table: classes

CREATE TABLE `classes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '课程id',
  `categories_id` int(10) unsigned DEFAULT '0' COMMENT '分类标签id',
  `type` tinyint(4) unsigned DEFAULT NULL COMMENT '课程类型 1:单节课程 2:重复课程 3:多开课时间课程',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '课程状态 1:正常;2:草稿;3下架',
  `userid` int(10) unsigned NOT NULL COMMENT '发起课程的用户id',
  `name` varchar(128) NOT NULL COMMENT '课程名称',
  `description` varchar(255) NOT NULL DEFAULT '' COMMENT '课程简介',
  `information` text,
  `images` text NOT NULL COMMENT '课程图片',
  `key_words` varchar(300) DEFAULT NULL COMMENT '关键词',
  `citycode` int(10) unsigned NOT NULL COMMENT '城市编码',
  `areacode` int(10) unsigned NOT NULL COMMENT '区编码',
  `address` varchar(128) NOT NULL DEFAULT '' COMMENT '课程地址',
  `longitude` decimal(9,6) unsigned NOT NULL COMMENT '上课地点经度 最多为9位 其中整数3位小数6位',
  `latitude` decimal(9,6) unsigned NOT NULL COMMENT '上课地点纬度 最多为9位 其中整数3位小数6位',
  `price` decimal(11,2) unsigned NOT NULL COMMENT '价格 最多为11位 其中整数9位小数2位',
  `buymin` int(11) unsigned DEFAULT '0' COMMENT '课程最少购买次数',
  `times_required` tinyint(3) unsigned DEFAULT '0' COMMENT '所需课时',
  `like_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '喜欢过课程的人数',
  `view_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '课程阅读次数',
  `amount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '总名额',
  `booked_amount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '已报名数',
  `starttime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '课程开始时间',
  `endtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '课程结束时间',
  `ctime` int(10) unsigned NOT NULL COMMENT '课程创建时间',
  `utime` int(10) unsigned NOT NULL COMMENT '课程更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@dschissler
Contributor

I'm getting Column 'uuid' doesn't make part of the column map.

@sergeyklay
Collaborator

@lxholding Could you please provide script to reproduce?

@sergeyklay
Collaborator

Fixed in the 3.0.x branch.

@sergeyklay sergeyklay closed this Aug 30, 2016
@sergeyklay sergeyklay added this to the 3.0.2 milestone Aug 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment