Welcome Guest, Not a member yet? Register   Sign In
Config class the best use of
#1

[eluser]我是一名刀客[/eluser]
I'm doing a project dating marriage

Data entry when:
Code:
<select>
     <option values ​​= "1"> School </ option>
     <option values ​​= "2"> degree </ option>
     <option values ​​= "3"> Master </ option>
     <option values ​​= "4"> Dr. </ option>
</ select>

So

Information stored in the database table is: 1,2,3,4 ..

Page is displayed, the need to convert, I now do:

Built in the config folder xxx.php, which wrote:
Code:
$config ['userdata']=
{
    ' education' => array (1 => 'school'), 2 => 'Degree', 3 => 'Master', 4 => 'Dr.'
}

In views where:

Code:
$userdata ['education'] [$row->education]    //Where {$row->educaion} is the value read from the database


Please help me identify my friends

thanks, all
#2

[eluser]LuckyFella73[/eluser]
I would prefer to set up a referencing DB table with
all you levels (School,degree,Master,Dr.) and do
a join sql query.

DB tables could look something like that:
Code:
// table "levels"
id    |    level
----------------------
1    |    School
2    |    degree
3    |    Master
4    |    Dr.

// table "entries"
id    |    level_id    | name(or whatever fields you have)
-------------------------------------------------------------------
1    |    3        | Paul
2    |    4        | Gregg
3    |    1        | Jack
4    |    1        | Ken
5    |    2        | Jean


Btw: the variable "config" is a reserved name regarding the
user guide!
#3

[eluser]我是一名刀客[/eluser]
thanks,sir

I heard a saying: there is an array where the database is less efficient than the present
I do not know whether my understanding is correct

In my project, there are many like this select
Many need to be stored as digital, then convert the display time

For example:


Gender: Female
Age: 37
Country: Philippines
State / Region: davao del sur
City: davao
Ethnicity: Asian
Appearance: Very Attractive
Height: 162 cm (5'4")
Weight: 35 kg (77 lbs)
Eye color: Black
Hair color: Black
Education: College - Some
Occupation: cashier
Religion: Christian - Catholic
Zodiac: Cancer
Born in the year of: Tiger
Marital status: Single
Have children: No
Wants children: Undecided
Willing to relocate: Yes
Smoking: Non smoker
Drinking: Non drinker

Should establish a dedicated their list? Like you just the same as the proposed table?

My English is poor, sorry
#4

[eluser]toopay[/eluser]
After load the config (if you didn't autoload your config file)
Code:
$userdata_config = $this->config->item('userdata');
$education = $userdata_config['education'][$row->education];
#5

[eluser]LuckyFella73[/eluser]
Quote:I heard a saying: there is an array where the database is less efficient than the present

Basically thats right but it's better to have all data in one place and if
you extend your data and relations you get into trouble soon. Think what
happens if you want to export all user data someday. In your DB you
have the digits 1,2,3,4 etc. but only looking at your sql export you don't
know what the digits stand for.

If you want to set up this dating-services I would do some research about
"DB normalization"!
#6

[eluser]我是一名刀客[/eluser]
Look forward to your research
#7

[eluser]toopay[/eluser]
Hey, Luckyfella were asked you to do that, not himself!




Theme © iAndrew 2016 - Forum software by © MyBB