Solved

How to query MySQL database from folder outside CodeIgniter application folder

Posted on 2014-03-13
4
854 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 108

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 108

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now