您好我Getting unknown property: app\models\ActiveCurriculum::period
period
列位于schead
表
我已使用此代码加入表格。
ActiveCurriculum::find()
->select('scstock.*')
->joinWith('schead')
->where(['schead.TrNo' => $TrNo])
->one();
你能帮助我吗?
编辑1(已修复)
SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;查看与您的MariaDB服务器版本相对应的手册,以便在#schead
附近使用正确的语法。TrNo
=' 29005''在第1行
正在执行的SQL是:SELECT scstock
。* FROM scstock
LEFT JOIN schead
WHERE schead
。TrNo
=' 29005'
编辑2:我设法修复了它,但我又遇到了一个新错误
"必须将join子句指定为连接类型,连接表和可选的连接条件数组。"
ActiveCurriculum::find()
->select(`scstock.*`)
->leftJoin(`schead`)
->where([`schead.TrNo` => $TrNo])
->one();
答案 0 :(得分:0)
ActiveCurriculum::find()->select('scstock.*')
->joinWith('schead')
->where(['schead.TrNo' => $TrNo])
->one();
// here joinWith('schead') means `schead` is name of the class
ActiveCurriculum::find()->select('scstock.*')
->joinLeft('schead','schead.scheadid=scstock.scheadid') // scheadid is the common field between two fields
->where(['schead.TrNo' => $TrNo])
->one();