Solved

How to query MySQL database from folder outside CodeIgniter application folder

Posted on 2014-03-13
4
897 Views
Last Modified: 2014-03-14
I need to query mysql database from a page which is not within the CodeIgniter folder structure.  The page is within a subfolder, one level in from the root.  The problem I get is that when I try to query the database like this:

$qryEvents = $this->db->query("SELECT * FROM tbldeadlines");

Open in new window


this returns an error.  I do autoload the database library in config/autoload.php, but I suspect that this does not apply to folders that are outside the CI application folder.  Question is:  What do I need to include on my page outside the CI application folder, so that I can query the database from that page?

Thanks.
0
Comment
Question by:DanielAttard
  • 2
  • 2
4 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39927646
My first question would be, "Why do you need the page to be outside the CodeIgniter structure?"  It would seem a lot easier to just put the page where it would work in a native way, right?
0
 

Author Comment

by:DanielAttard
ID: 39927990
Good suggestion Ray.Why make it complicated, right?

My question is: into what folder should the page go? I don't know how to change the URL parameter to refer to the correct path, whatever that is.  Controller? View?
0
 

Author Closing Comment

by:DanielAttard
ID: 39928313
Your comment got my thinking on the right track.  There was no need for me to be putting files outside the CodeIgniter structure.  I simply had to move my code into a controller, and then into a specific method.  Then I could use `controller/method` as the path for the URL parameter.  All working tickety-boo now.  Thanks.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39929050
Glad you've got it sorted out.  Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to count occurrences of each item in an array.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question