Solved

How to query MySQL database from folder outside CodeIgniter application folder

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
This article discusses four methods for overlaying images in a container on a web page
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 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