Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8278679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:05:47+00:00 2026-06-08T09:05:47+00:00

Using Codeigniter (v1.7.2) Active Record Class to query a MSSQL Database (external DB, I

  • 0

Using Codeigniter (v1.7.2) Active Record Class to query a MSSQL Database (external DB, I don’t control table or field names)

The following Code:

$this->db->select('[Key Field], MemberInfo.OtherField');
$this->db->limit(10);
$this->db->from('primaryTable');
$this->db->join('MemberInfo', '[Member Number] = Member_Number', 'left');
$this->db->where('[Member Number]  = 573');
$this->db->where('[Incident Date] BETWEEN '. $DateStart . ' AND ' . $DateEnd);

Produces the following Query (which has a syntax error)

SELECT  TOP 10 [Key Field], MemberInfo.OtherField
FROM primaryTable
LEFT JOIN MemberInfo ON Member Number] = Member_Number
WHERE [Member Number] = '573'
AND [Incident Date] BETWEEN 2012-01-01 AND 2012-07-19

Note the JOIN clause, which is missing the opening ‘[‘ on the field name

I tried using double quotes, which yielded the same result.

Anyone have ideas, is this a known bug in 1.7.2 (which I know is old, working up updating)?

UPDATE
issue is present in 2.1.2 also

Accepted answer below is also the fix for 2.1.2: change the regex check in the JOIN function to look for the opening [

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:05:48+00:00Added an answer on June 8, 2026 at 9:05 am

    The problem is in the parameter ON. There does not exist an integrated solution in the framework (not in version 2).

    You have 2 options:

    1. Altering the core of the library active_record

    2. Write the query in a complete chain with concatenations using $this->db->query();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to
I want to implement a sql query using CodeIgniter Active Record class. The query
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I'm using Codeigniter's Active Record Class. So the query looks something like this: $query
i have been using codeigniter active record class for database acces, But one thing
I'm using Codeigniter and the Active Record class to build a simple API in
Im currently using CodeIgniters active record class to UPDATE a MySQL table. One of
I am trying to form a query using codeigniter's active record, the search is
I have a query written using codeigniters active record class. When the query is
I'm using CodeIgniter's Active Record Classes and I'm retrieving an error using the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.