![]() |
When exactly is the database loaded? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: When exactly is the database loaded? (/showthread.php?tid=26448) |
When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]jwindhorst[/eluser] I'm creating an application for which I would like to be able to pull some user defined configuration settings from the DB to be accessed globally. I was going to add them to the config file but it would appear I don't have the DB at that point. Thanks! When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]jwindhorst[/eluser] Maybe I'm asking the wrong question. I want users to be able to customize settings like LOGO_IMAGE_PATH, and then save that path in the DB. I want to be able to access this path always, globally, without hitting the DB in every controller/view, and I don't want it to be a constant that would require the user to edit a file. Hope that is more clear. When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]Colin Williams[/eluser] I would get over the idea of hitting the DB on every page load. If it really does concern you, you can use CI's built-in query caching. When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]jwindhorst[/eluser] Yea, I was just thinking about that as well, but there is another hurdle with my plan to take over the world. I want to set CSS values based on DB settings. So I moved stylesheet.css to stylesheet.php and use: Code: <?php header("Content-type: text/css"); ?> Code: <link rel="stylesheet" type="text/css" media="screen" href="style.php"> The PHP is firing inside of the CSS file, but I don't seem to have access to CI in there. Any thoughts on the new and improved problem? I did try adding get_defined_constants() and get_defined_vars() inside the php/css file but they only get the big php stuff, nothing application specific. Thanks! When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]Colin Williams[/eluser] Well, if you want to hit a CI page, take what you have in style.php and put it in a Controller file, and point your URI to that Controller. When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]jwindhorst[/eluser] True, but then it's not global to the application. Currently the css file is in /assets/css/template_name/ directory. Would moving it to /system/application/views/template_name/css/ get my CI core back? When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]Colin Williams[/eluser] No. It has to be run through CI. So, you'd have application/controllers/style.php Code: class Style extends Controller { and the URI would be http://www.example.com/index.php/style When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]jwindhorst[/eluser] Right, but then it is all echo'd out in the controller right? Making for ugly inline styles in the source which I was trying to avoid. I'm not sure if it can be done any other way, but I would much prefer a more elegant solution. When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]Colin Williams[/eluser] You really are failing to connect the dots I'm showing you. Code: class Style extends Controller { Code: <link rel="stylesheet" type="text/css" media="screen" href="/index.php/style"> When exactly is the database loaded? - El Forum - 01-13-2010 [eluser]jwindhorst[/eluser] Perhaps the reason I wasn't seeing it that way is because I have my own version of the view function in MY_Loader to grab header and footer templates and load numerous views between: Code: function view($views, $vars = array(), $return = FALSE) But I could likely create a work around in there for the css files. |