Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lxholding opened this issue Dec 8, 2015 · 3 comments
Closed
Labels
bug A bug report status: medium Medium
Milestone

Comments

@lxholding
Copy link

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

This comment was marked as abuse.

@sergeyklay sergeyklay added the need script to reproduce Script is required to reproduce the issue label Jul 21, 2016
@sergeyklay
Copy link
Contributor

@lxholding Could you please provide script to reproduce?

@sergeyklay
Copy link
Contributor

Fixed in the 3.0.x branch.

@sergeyklay sergeyklay added this to the 3.0.2 milestone Aug 30, 2016
@sergeyklay sergeyklay added Bug - Medium and removed need script to reproduce Script is required to reproduce the issue labels Aug 30, 2016
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

4 participants