1
私はcodeigniterに大きな問題があります。codeigniter join()メソッドでmysql関数を書くには
codeigniter join()関数でFIND_IN_SET mysql関数を使いたいです。しかし、問題はcodeigniterがFIND_IN_SETをフィールド名とみなすことです。
コードの下に確認してください:CodeIgniterので与えMySQLのクエリ出力で
$this->db->select("gcpo.promotional_offer_id,gcpo.promotional_offer_name,gcpo.promotional_offer_code,gcpo.promotional_offer_type,gcpo.promotional_offer_discount,gcpo.promotional_offer_min_amount,gcpo.promotional_offer_uses_per_offer,gcpo.promotional_offer_start_date,gcpo.promotional_offer_end_date,name,gcpo.promotional_offer_is_active,gcpo.promotional_offer_added_date,count(gcopo.promotional_offer_code) as cntP");
$this->db->from("promotional_offer gcpo");
$this->db->join("customer_groups", "FIND_IN_SET(id,promotional_offer_customer_group) > 0");
$this->db->join("order_promotional_offer gcopo", "gcopo.promotional_offer_code=gcpo.promotional_offer_code","left");
$this->db->group_by('gcpo.promotional_offer_code');
$this->db->limit($_GET['iDisplayLength'], $start);
$this->db->order_by($sort_array[$_GET['iSortCol_0']], $_GET['sSortDir_0']);
$query = $this->db->get();
:
SELECT `gcpo`.`promotional_offer_id`, `gcpo`.`promotional_offer_name`, `gcpo`.`promotional_offer_code`, `gcpo`.`promotional_offer_type`, `gcpo`.`promotional_offer_discount`, `gcpo`.`promotional_offer_min_amount`, `gcpo`.`promotional_offer_uses_per_offer`, `gcpo`.`promotional_offer_start_date`, `gcpo`.`promotional_offer_end_date`, `name`, `gcpo`.`promotional_offer_is_active`, `gcpo`.`promotional_offer_added_date`, count(gcopo.promotional_offer_code) as cntP FROM (`gc_promotional_offer` gcpo) JOIN `gc_customer_groups` ON `FIND_IN_SET`(`id,promotional_offer_customer_group)` > 0 LEFT JOIN `gc_order_promotional_offer` gcopo ON `gcopo`.`promotional_offer_code`=`gcpo`.`promotional_offer_code` GROUP BY `gcpo`.`promotional_offer_code` ORDER BY `gcpo`.`promotional_offer_added_date` desc LIMIT 10
を、今あなたがで検討し、フィールド名のようにありますmysqlのクエリでFIND_IN_SET機能を見つけてくださいcodeigniter。
こんにちはTreast、私はすでにFIND_IN_SET機能を使用し参加するが、CodeIgniterのではなく、直接mysqlコマンドプロンプトに対話していないよ 。 しかし、私がcodeigniterを使っているときは、そのフィールドを考慮してください。私の質問にmysqlクエリをチェックしてください。 私はまた、条件がどこでうまくいったのかを試しましたが、他の問題ではうまくいきました。 ご返信ありがとうございます。 私のプロジェクトであなたのコードを試してみます。これがうまくいくなら、私はあなたに知らせるでしょう ありがとう –