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

  • Home
  • SEARCH
  • 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 7161927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:38:59+00:00 2026-05-28T13:38:59+00:00

I really like CodeIgniter’s Active Record and how nicely it allows all my needed

  • 0

I really like CodeIgniter’s Active Record and how nicely it allows all my needed database queries.

But I’ve also been reading about ORMs like Doctrine. When I read Doctrine’s documentation, it does not seem as clear to use as Active Record, and I can’t see what makes it better (if it is).

What does Doctrine allow that is not possible with Active Record? Does Doctrine make the same job faster, easier, better? Or does it do things Active Record cannot do?

Best would be if people could post examples of tasks showing what we’re talking about.

Thanks,
Matthew

  • 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-05-28T13:39:00+00:00Added an answer on May 28, 2026 at 1:39 pm

    Doctrine is a full-fledged ORM that implements the active record pattern. CodeIgniter’s active record class is a query builder/database wrapper that is based on a “modified” version of the pattern.

    Disclaimer: I have never used Doctrine. I will try my best to illustrate the differences between CodeIgniter’s active record implementation and Doctrine, based on my understanding.

    Using CodeIgniter’s active record class, you might implement a model like this:

    class User_model extends CI_Model
    {
    
        public function get_user_by_username($username)
        {
            // Build query using active record methods
            $this->db->where('username', $username);
            $this->db->where('active', 1);
    
            // Execute query
            $query = $this->db->get('users');
    
            // Return results
            return $query->result();
        }
    
        // ...
    
    }
    

    You are basically building the query using the active record methods. It’s easy to see how each method (where(), get(), etc) maps to raw SQL. The advantage to using the active record methods as opposed to just $this->db->query() is that CodeIgniter compiles each query based on the database driver you are using. Other than that, CodeIgniter’s active record implementation doesn’t really do much. Any queries you need, you’ll need to create. I hope I’ve illustrated how the active record methods are similar to a query builder.

    Note that that the following sample code may be incorrect. Using Doctrine, you might have a model like this:

    /** @Entity */
    class User
    {
    
        /** @Column(type="integer") */
        private $id;
    
        /** @Column(length=50) */
        private $username;
    
        // ...
    
    }
    

    Then to use the model and the associated active record functionality, you would do something like this:

    // Instantiate object
    $user = new User();
    
    // Set properties
    $user->username = 'some_username';
    
    // Save object
    $user->save();
    
    // Access properties
    echo $user->id;
    

    This is just scratching the surface in terms of what Doctrine can do. You can set default values for properties or specify relationships between tables. Notice how I didn’t write any SQL or build the query. I just set the properties of the object and then saved it. Doctrine takes care of the rest.

    Note that Doctrine includes its own query builder, so in a way it does what CodeIgniter’s active record does, and more.

    Using Doctrine is similar to CakePHP’s or Ruby on Rails’ implementation of the active record pattern. You could take a look there for additional insight into the pattern. CakePHP’s examples might be particularly easy to digest if you’re coming from a CodeIgniter background.

    To answer some of your other questions, I don’t think there’s anything that makes Doctrine better than the CodeIgniter active record methods. It may be more advanced, but like any other library, you want to pick the best tool for the job. If you are happy with CodeIgniter’s active record methods and you see no need for an advanced ORM, then skip it.

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

Sidebar

Related Questions

I really like Xml for saving data, but when does sqlite/database become the better
Reading all about PHP frameworks, CodeIgniter seems really nice in that I like it's
We really like Psyco to speed things up, but it also has some drawbacks:
I really like DevX components, but they are pretty expensive, maybe anyone knows free
I really like how Consolas looks with ClearType enabled but unfortunately it makes everything
I've been using Codeigniter for the past two years and really have become a
I really like py.test , but I am having lots of difficulty understanding how
i use a simple PHP framework (like Codeigniter) without ORM. I have a database
I use CodeIgniter and i love it, but i don't know whether it's really
As a former CodeIgniter user, I would really like to migrate to another framework.

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.