Welcome Guest, Not a member yet? Register   Sign In
Mantain an array avaible
#1

[eluser]Isern Palaus[/eluser]
Hello,

I want to have an make available an array in the administration area of my application.

I actually have a languages system that allows you to use a lot of languages. When you add a item the application looks in the database for the languages that are currently active. This can be one or ten. They are stored in array and consulted a lot of times if you are in the administration application.

What can I do? I think that extend the Controller is a option but for only add an array? There is another solution?

Thanks in advance,
Isern
#2

[eluser]überfuzz[/eluser]
Have you consider a cookie?

Edit, sorry a session. Set the language while logging in. User can have default language or chose from select-->option-list.
#3

[eluser]Isern Palaus[/eluser]
Hello,

I'm actually using this. But what I was asking how to have an array in the hole admin area defining it only one time. I'm using a query a lot of times, the same query and I want to have it already stored.

Thank you anyway! ;D

Isern
#4

[eluser]jedd[/eluser]
[quote author="Isern Palaus" date="1257960630"]
What can I do? I think that extend the Controller is a option but for only add an array? There is another solution?
[/quote]

What's wrong with extending the Controller? Are you worried that your requirements are too heavy, or too light, for this approach?
#5

[eluser]überfuzz[/eluser]
Code:
$user['language'] = "Swahili";  //Set this to selected in the select field.
$user['name'] = "Ronald Raygun"; //from query
$user['access'] = "3";   /from query

Now you just have to jam $user into a session.
#6

[eluser]Isern Palaus[/eluser]
[quote author="jedd" date="1257962530"][quote author="Isern Palaus" date="1257960630"]
What can I do? I think that extend the Controller is a option but for only add an array? There is another solution?
[/quote]

What's wrong with extending the Controller? Are you worried that your requirements are too heavy, or too light, for this approach?[/quote]

I've no problem with that but, for only an array... if there is another solution faster and viable would be welcome.

By the way, if extend the controller is the solution... you can define an array on the main controller but how to make the data avaible? Doing the db query on this main controller and defining the data on the array?

Thank you!
Isern
#7

[eluser]jedd[/eluser]
[quote author="Isern Palaus" date="1257962802"]
... for only an array... if there is another solution faster and viable would be welcome.
[/quote]

Faster to code, or faster to execute?

If the former, in the time it's taken to discuss this, you could have written it. If the latter, the limiting factor will be the DB lookup. If you want the data available in all your controllers you'd be hard pushed to find a faster way of getting that data there.

Quote:... you can define an array on the main controller but how to make the data avaible? Doing the db query on this main controller and defining the data on the array?

I don't understand the first question. If you can define an array, you then just refer to the array, surely: $this->array_of_stuff_I_want_everywhere

Do the DB query in MY_Controller, of course, to acquire this data.
#8

[eluser]Isern Palaus[/eluser]
[quote author="jedd" date="1257968847"][quote author="Isern Palaus" date="1257962802"]
... for only an array... if there is another solution faster and viable would be welcome.
[/quote]

Faster to code, or faster to execute?

If the former, in the time it's taken to discuss this, you could have written it. If the latter, the limiting factor will be the DB lookup. If you want the data available in all your controllers you'd be hard pushed to find a faster way of getting that data there.

Quote:... you can define an array on the main controller but how to make the data avaible? Doing the db query on this main controller and defining the data on the array?

I don't understand the first question. If you can define an array, you then just refer to the array, surely: $this->array_of_stuff_I_want_everywhere

Do the DB query in MY_Controller, of course, to acquire this data.[/quote]

Hello jedd,

Thank you for your reply.

At this moment, I'm trying to do my applications well-coded and doing it fast it's not a way Tongue! I'm only looking for the best method for organization, optimization... I personally think that, after reading your replies, using a controller and extend it will be the best option.

Returning to this point, extending the main controller... It can't be directly extended, no? Because there is no CI_Controller to extend. I'll have to extend Controller and then extend my NewController. That's right?

Thanks,
Isern
#9

[eluser]jedd[/eluser]
[quote author="Isern Palaus" date="1258050865"]
Returning to this point, extending the main controller... It can't be directly extended, no? Because there is no CI_Controller to extend. I'll have to extend Controller and then extend my NewController. That's right?
[/quote]

I'm confused by this.

Have you read about MY_Controller in the user guide?

If not, go read it now.

You don't need to refer to CI_Controller anywhere, or have a NewController. Your MY_Controller lives in your libraries directory, and extends Controller. Your various normal controllers then extend MY_Controller. Seriously, this is very well documented both in the user guide, and in the wiki.
#10

[eluser]Unknown[/eluser]
very good




Theme © iAndrew 2016 - Forum software by © MyBB