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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:25:30+00:00 2026-06-07T12:25:30+00:00

is it possible to declare constants in /application/config/constant.php from a DB table? I’m trying

  • 0

is it possible to declare constants in /application/config/constant.php from a DB table?

I’m trying to do something like this.

$result = $this->db->select( 'attr, value' )->from( 'app_conf')->where( 'city', 53 )->or_where( 'city', -1 )->order_by( 'city' )->get();
$app_conf = $result->result_array();
// var_dump( $app_conf );
foreach( $app_conf as $row )
{
    define( "_{$row['attr']}", $row['value'] );
}

but right now I have to do it in every controller I create, so duplicating code and requiring to do changes all over if needed, which seems unnecessary!

  • 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-07T12:25:31+00:00Added an answer on June 7, 2026 at 12:25 pm

    Extend the CI Controller and place it in the application/core directory as MY_Controller. In the extended controller’s constructor place the above code. Now you can extend it from your controllers to execute the same code. So you are not required to write this code again and again.

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

Sidebar

Related Questions

I am wondering if its possible to declare a symbol constant in php I
Possible Duplicate: Is it possible to declare an array as constant Is it possible
It is possible? DECLARE @vTableName varchar(50) SET @vTableName = (SELECT TableName FROM qms_Types WHERE
So, in a non-class type of situation, I can do something like this: int
I would like to declare some user-defined compiler-constants to keep my specification files as
Is it possible to declare a constant Guid in C#? I understand that I
In C#, I would like to figure out if it's possible to declare an
I need to convert a huge number of constants from an application. Is it
I want to ask you if is possible to declare a constant in SQL
Imagine I have some XML that looks like this: DECLARE @xml XML SET @xml

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.