Zend Framework中的model中关联查询:
/**
* 返回【单个研讨会】的详细信息
* @param webinarid
* @return Array
*/
public function getWebinarInfoById($webinarid) {
$selectString = 'a.`id` as id,
`title`,
`begin_time`,
`end_time`,
`basic_intro`,
`detail_intro`,
`sponsor_id`,
`recommend_if`,
`speakername`,
`speaker_photo`,
`office_position` ,
`speakerintro` ,
`views` ,
`company_name` ,
`sponsor_intro` ,
`sponsor_logo` ,
`url`
';
$webinarid = intval ( $webinarid );
$webinarInfo = $this->_db->fetchRow ( "SELECT {$selectString} FROM `cnt_webinar` as a,
`cnt_webinar_sponsor` as b
WHERE a.id={$webinarid}
AND a.sponsor_id = b.id;
" );
return $webinarInfo;
}
关联插入:
有两个表:表A和表B,A表中有id, uid,asker,B表中也有uid,username。现在我想更新A表中的uid变成B表中的uid,条件是A表中的username=B表中的username:
UPDATE `A` AS a,`B` AS b SET a.uid = b.uid WHERE b.username = a.asker
浙公网安备 33010602011771号