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 8923875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:15:01+00:00 2026-06-15T07:15:01+00:00

i use Active record for inserting values to DB. All other type of queries

  • 0

i use Active record for inserting values to DB.

All other type of queries i do with custom query as it’s much easier but the active record insert is quite nice.

So i have this code :

    $comment = array (
'point_id' => $object->id,
'title' => $object->title,
'comment' => $object->comment,
'author_name' => $object->author_name,
'is_temp' => 0,
'parent_id' => $object->parent_id

);
return $this->db->insert('comments', $comment);

Now i want to be able to set is_temp as a subquery result, which is :

(SELECT allow_user_comments from subjects where id='somevalue')

How would one achive that?

I was hoping to avoid using third party libraries.

  • 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-15T07:15:02+00:00Added an answer on June 15, 2026 at 7:15 am

    Well, i doubt the fact that that’s how you’re supposed to do it, but ain’t CI all about that?

    This is how i got it to work (removing is_temp from the $comment array ofcourse):

    $this->db->set($comment);
    $this->db->set('is_temp',
    '(SELECT allow_user_comments from subjects where id='.$subject_id.')',FALSE);
    $this->db->insert('comments');  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to use codeigniters active record system to construct a query
I'm using Active Record with ActiveRecord Facility, and am trying to use a custom
I'm using codeigniter and most of the time use active record for my queries
I am using subsonic 2.2 with Oracle provider. I can use active record but
I'm trying to use the new Active Record Query Interface for Rails 3. My
I'd like to use an Active Record design pattern in a few of my
I have a non-rails application that I want to use rails active-record migrations with.
How would I use active record in this case: I have two tables: Users,
Is it possible to use delegate in your Active Record model and use conditions
When I try to use CDbCriteria to count records I get Active record Hotels

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.