0

I have this in my code and im using codeigniter yet it's producing an error

        // make call to db and create a file
        $this->db->select("*");
        $this->db->from("mst_global_settings mgs");
        $this->db->join("trans_global_settings tgs", "mgs.global_name_id=tgs.global_name_id", "inner");
        $this->db->where('`tgs`.lang_id', $lang_id);
        $query = $this->db->get();
        $result = $query->result_array();
        $tmp_array = array();
        foreach ($result as $global_array) {
            $tmp_array[$global_array["name"]] = $global_array["value"];
        }

Codeigniter is giving me the following error

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tgs`.`lang_id` = 'en'' at line 4

SELECT * FROM (`p931_mst_global_settings` mgs) INNER JOIN `p931_trans_global_settings` tgs ON `mgs`.`global_name_id`=`tgs`.`global_name_id` WHERE `p931_`tgs`.`lang_id` = 'en'

Filename: /models/mdl_common.php

Line Number: 26
1
  • Try removing backticks. Commented Jun 16, 2015 at 13:10

1 Answer 1

2

The problem is your single quotes.

Change this:

$this->db->where('`tgs`.lang_id', $lang_id);

To this:

$this->db->where('tgs.lang_id', $lang_id);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.