各製品ラインのテーブルでリクエストを作成したいのですが、製品 ID が別のテーブルに存在するかどうかを制御する必要があります。
テーブル内製品
id name
1 abc
2 def
3 ghi
別のテーブルで
id id_product id_catalogue
1 2 1
2 3 2
たとえば、幅id_catalogue 1を尋ねるときにこの結果が必要です
id produt name value id_catalogue
1 abc false null
2 def checked 1
3 ghi false null
1 つのクエリのみに含まれている必要があります
実際、私はこれを持っています。うまく機能しないクエリの幅を広げます
id produt name value id_catalogue
1 abc false null
2 def checked 1
3 ghi checked null
ありがとう
$this->datatables->select("frs.raison_sociale as fournisseur,f.titre as famille,sf.titre as sous_famille,p.attribut as attribut,p.pa_centrale as prix_achat,p.marge_centrale as marge_centrale,p.pa_magasin as pa_magasin,p.marge_magasin as marge_magsin,p.prix_ht_public as public_ht,p.prix_ttc_public as public_ttc,p.id as id
,IF (cc.id_catalogue='".$id."', 'checked', FALSE) checked
",FALSE)
->from('cat_produits p')
->where('p.suppr','0')
->join('fournisseurs frs','frs.id=p.id_fournisseur', 'left')
->join('cat_familles f','f.id=p.id_famille', 'left')
->join('cat_sous_familles sf','sf.id=p.id_sous_famille', 'left')
->join('cat_cat_produits cc','cc.id_produit=p.id','left')
->edit_column('id', '<input type="checkbox" name="produits[]" value="" id="ck_pdt_$1" class="check_ligne_pdt" $2>', 'id,checked');
編集: クエリは機能しますが、2つのエラーがあります:
missing cc.id_catalogue in select
および前:
IF (cc.id_catalogue='".$id."', 'checked', '') checked
後(欠落):
IF (cc.id_catalogue='".$id."', 'checked', '') as checked