sharehua
(8080268)
1
‘b’ => array(self::BELONGS_TO, ‘A’, ‘instance_id’),
1.0的情况
A model的值
[CActiveRecord:_attributes] => array
(
[class_] => 'Task'
[hasvars] => 1
[key_] => '2'
[name] => '11、1111(11.00分 可执行11次)'
[priority] => 0
[procdefid] => 'processTaskObjective-1'
[state] => 'created'
[susphiststate] => null
[parent_id] => null
[subProcinst_id] => null
[superExec_id] => null
[id] => '14'
[id_] => 'processTaskObjective.14'
[instance_id] => '14'
)
relation b的值
[CActiveRecord:_attributes] => array
(
[id] => '14'
[activityname] => null
[class_] => 'Task'
[dbversion] => '0'
[hasvars] => '1'
[hisactinst] => null
[id_] => 'processTaskObjective.14'
[key_] => '2'
[name] => '11、1111(11.00分 可执行11次)'
[parentIdx] => '0'
[priority] => '0'
[procdefid] => 'processTaskObjective-1'
[state] => 'created'
[susphiststate] => null
[instance_id] => '14'
[parent_id] => null
[subProcinst_id] => null
[superExec_id] => null
)
1.1的情况
A model的值
[CActiveRecord:_attributes] => array
(
[class_] => 'Task'
[hasvars] => 1
[key_] => '2'
[name] => '11、1111(11.00分 可执行11次)'
[priority] => 0
[procdefid] => 'processTaskObjective-1'
[state] => 'created'
[susphiststate] => null
[parent_id] => null
[subProcinst_id] => null
[superExec_id] => null
[id] => '19'
[id_] => 'processTaskObjective.19'
[instance_id] => '19'
)
relation b的值
[CActiveRecord:_attributes] => array
(
[id] => '19'
[activityname] => null
[class_] => 'Task'
[dbversion] => '0'
[hasvars] => '1'
[hisactinst] => null
[id_] => null
[key_] => '2'
[name] => '11、1111(11.00分 可执行11次)'
[parentIdx] => '0'
[priority] => '0'
[procdefid] => 'processTaskObjective-1'
[state] => 'created'
[susphiststate] => null
[instance_id] => null
[parent_id] => null
[subProcinst_id] => null
[superExec_id] => null
)
差别在于 id_和instance_id赋值不上。
a的create是
if($root->save()){
$root->id_=$processDefinition->key.'.'.$root->id;
$root->instance_id=$root->id;
$pHistProcinst->id_=$root->id_;
$pHistProcinst->update();
$root->update();
}
a的create和b的relation关联,是在一个transiton里面的。
sharehua
(8080268)
5
没save成功,我在trasition提交之前,取的relation,1.0是支持的,1.1不支持。
save和update,还有取relation都是在一个transition中。
qiang
(Qiang Xue)
6
save()没成功是因为验证出错。把所有的验证消息显示出来看看。1.1在safe attributes方面有改动。请参看1.1升级细节。
sharehua
(8080268)
7
不是验证错误的,save是正确执行的。
我说的save不成功是没有写入数据到数据库,我把save后面做了调试语句,他是执行了$root->update();了
sharehua
(8080268)
8
我把其他代码都注销了,然后让程序没有错误顺利执行,发现 id_和instance_id没有保存到数据库–这是1.1的情况下。
1.0的情况下, id_和instance_id是保存到数据库。
qiang
(Qiang Xue)
9
你是指1.1下$pHistProcinst->update();没有更新数据?
sharehua
(8080268)
10
$root->update 没有更新数据。
$pHistProcinst->update我还没测试,不清楚。
sharehua
(8080268)
12
if($root->save()){
Util::file('------------------------------------------------------',1);
$root->id_=$processDefinition->key.'.'.$root->id;
$root->instance_id=$root->id;
$pHistProcinst->id_=$root->id_;
$pHistProcinst->update();
if($root->update()){
Util::file('---------222222---------------------------------------------',1);
}
}
这两个日志,在1.0和1.1都是执行的,但在1.1没有更新数据到数据库。
qiang
(Qiang Xue)
14
你得回答我的问题啊。我问的是你是否检查过log里记录的update SQL语句了。另外,象这种问题其实你用单步调试应该就能发现问题所在了。
sharehua
(8080268)
15
2010/01/28 20:57:14 [trace] [cn.sl.f] '------------------------------------------------------'
2010/01/28 20:57:14 [trace] [system.db.ar.CActiveRecord] PHistProcinst.update()
2010/01/28 20:57:14 [trace] [system.db.ar.CActiveRecord] PHistProcinst.updateByPk()
2010/01/28 20:57:14 [trace] [system.db.CDbCommand] Executing SQL: UPDATE `_bpm4_hist_procinst` SET `procdefid`=:yp0, `state`=:yp1, `key_`=:yp2, `start`=:yp3, `end`=:yp4, `id`=:yp5, `id_`=:yp6 WHERE `_bpm4_hist_procinst`.`id` IS NULL. Bind with parameter :yp0='processTaskObjective_1', :yp1='active', :yp2='1', :yp3='2010-01-28 20:57:14', :yp4=NULL, :yp5=2, :yp6='processTaskObjective.2'
2010/01/28 20:57:14 [trace] [system.db.ar.CActiveRecord] PExecution.update()
2010/01/28 20:57:14 [trace] [system.db.ar.CActiveRecord] PExecution.updateByPk()
2010/01/28 20:57:14 [trace] [system.db.CDbCommand] Executing SQL: UPDATE `_bpm4_execution` SET `class_`=:yp0, `hasvars`=:yp1, `key_`=:yp2, `name`=:yp3, `priority`=:yp4, `procdefid`=:yp5, `state`=:yp6, `susphiststate`=:yp7, `parent_id`=:yp8, `subProcinst_id`=:yp9, `superExec_id`=:yp10, `id`=:yp11, `id_`=:yp12, `instance_id`=:yp13 WHERE `_bpm4_execution`.`id` IS NULL. Bind with parameter :yp0='Task', :yp1=1, :yp2='1', :yp3='1、11(1.00分 可执行11次)', :yp4=0, :yp5='processTaskObjective-1', :yp6='created', :yp7=NULL, :yp8=NULL, :yp9=NULL, :yp10=NULL, :yp11=2, :yp12='processTaskObjective.2', :yp13=2
2010/01/28 20:57:14 [trace] [cn.sl.f] '---------222222---------------------------------------------'
这是日志,执行了update,但他指定的主键是 null,明显错误,应该是2.
sharehua
(8080268)
16
这是1.0的日志
2010/01/28 21:02:29 [trace] [cn.sl.f] '------------------------------------------------------'
2010/01/28 21:02:29 [trace] [system.db.ar.CActiveRecord] PHistProcinst.update()
2010/01/28 21:02:29 [trace] [system.db.ar.CActiveRecord] PHistProcinst.updateByPk()
2010/01/28 21:02:29 [trace] [system.db.CDbCommand] Executing SQL: UPDATE `_bpm4_hist_procinst` SET `procdefid`=:yp0, `state`=:yp1, `key_`=:yp2, `start`=:yp3, `end`=:yp4, `id`=:yp5, `id_`=:yp6 WHERE `_bpm4_hist_procinst`.`id`=3. Bind with parameter :yp0='processTaskObjective_1', :yp1='active', :yp2='1', :yp3='2010-01-28 21:02:29', :yp4=NULL, :yp5=3, :yp6='processTaskObjective.3'
2010/01/28 21:02:29 [trace] [system.db.ar.CActiveRecord] PExecution.update()
2010/01/28 21:02:29 [trace] [system.db.ar.CActiveRecord] PExecution.updateByPk()
2010/01/28 21:02:29 [trace] [system.db.CDbCommand] Executing SQL: UPDATE `_bpm4_execution` SET `class_`=:yp0, `hasvars`=:yp1, `key_`=:yp2, `name`=:yp3, `priority`=:yp4, `procdefid`=:yp5, `state`=:yp6, `susphiststate`=:yp7, `parent_id`=:yp8, `subProcinst_id`=:yp9, `superExec_id`=:yp10, `id`=:yp11, `id_`=:yp12, `instance_id`=:yp13 WHERE `_bpm4_execution`.`id`=3. Bind with parameter :yp0='Task', :yp1=1, :yp2='1', :yp3='1、11(1.00分 可执行11次)', :yp4=0, :yp5='processTaskObjective-1', :yp6='created', :yp7=NULL, :yp8=NULL, :yp9=NULL, :yp10=NULL, :yp11=3, :yp12='processTaskObjective.3', :yp13=3
2010/01/28 21:02:29 [trace] [cn.sl.f] '---------222222---------------------------------------------'
这里的id不是null而是save后的id
qiang
(Qiang Xue)
19
framework/db/ar/CActiveRecord.php