多个jquery数据表codeigniter

时间:2013-06-08 10:25:57

标签: mysql codeigniter datatables

我想在每个产品系列的表格上发出请求,但我必须控制产品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

它必须只在一个查询中

实际上我有这个,宽度我的查询谁不工作

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');

编辑查询有效,我有两个错误:

    missing cc.id_catalogue in select 

之前:

     IF (cc.id_catalogue='".$id."', 'checked', '')  checked

之后(缺少):

       IF (cc.id_catalogue='".$id."', 'checked', '') as checked

0 个答案:

没有答案
相关问题