On 09/27/2017 11:31 AM, Jim Hu wrote:
> Query: SELECT  
> annotation_id,row_id,original_row_data,annotation_timestamp,user_id,team_id,session_id,annotation_inning
>   FROM `unittest_cacao_annotation` INNER JOIN `unittest_cacao_user` ON 
> ((annotation_user = cacao_user.id))   WHERE annotation_id = "6057"  
> Function: CacaoModelAnnotation::load
> Error: 1054 Unknown column 'cacao_user.id' in 'on clause' (localhost)
MediaWikiTestCase sets $wgDBprefix to cause database queries to refer to
temporary tables instead of the original tables. If your code does not
handle table prefixes correctly, you can get such an error message.
>                                       'cacao_user' => array('INNER JOIN', 
> 'annotation_user = cacao_user.id' ),
To make a query like this work with a table prefix, you should alias the
referenced table ("cacao_user" in this case), then in the condition,
refer to the table using the alias:

$result = $dbr->select(
    array( 'cacao_annotation', 'u' => 'cacao_user' ),

[...]

'cacao_user' => array( 'INNER JOIN', 'annotation_user = u.id' ),

-- 
Kevin Israel -- Wikipedia editor, MediaWiki developer
https://en.wikipedia.org/wiki/User:PleaseStand

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to