php - model Search with join 2 DB's YII2 -
i need compare 1 field "original" (db1 mysql) search, table database , (db2 sql) got error :
sqlstate[42s02]: base table or view not found: 1146 table 'nexus.reparossigitm' doesn't exist sql being executed was: select intragovanalitico
.* intragov_analitico
left join reparossigitm
on reparossigitm
.if_tqi_codigo
= tqi_codigo
.tqi_codigo
how can leftjoin 2 models ?
my model 1
class intragovanaliticosearch extends intragovanalitico { [...] public function search($params) { // that's ok if doesnt need compare db field > //$query = intragovanalitico::find()->where(['if_poi_nome' => 'reativo','pl_operacao_pacote' => 'intragov','al_tipo_alarme' => 'disp']); // try > $query = intragovanalitico::find() ->select('intragovanalitico.*') ->leftjoin('reparossigitm', '`reparossigitm`.`if_tqi_codigo` = `tqi_codigo`.`tqi_codigo`') ->where('intragovanalitico.if_poi_nome' => 'reativo','intragovanalitico.pl_operacao_pacote' => 'intragov', 'intragovanalitico.al_tipo_alarme' => 'disp' ) ->all(); [...] }
thanks ^^
@imtiaz still cannot use 2 dbs
sqlstate[42s02]: [microsoft][odbc driver 11 sql server][sql server]invalid object name 'intragov_analitico'. sql being executed was: select * intragov_analitico inner join reparos_sigitm on intragov_analitico.if_tqi_codigo = reparos_sigitm.tqi_codigo
query :
$dbx = new connection(yii::$app->dbsql65sigitm); $sql = "select * intragov_analitico inner join reparos_sigitm on intragov_analitico.if_tqi_codigo = reparos_sigitm.tqi_codigo"; $dbx- >createcommand($sql)->queryall();
Comments
Post a Comment