Solved

How to query MySQL database from folder outside CodeIgniter application folder

Posted on 2014-03-13
4
805 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad you've got it sorted out.  Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP Variable into a number 3 34
windows 10 bash shell 4 32
update field on focusout 15 19
writting html or javascript in PHP 8 9
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.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 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

15 Experts available now in Live!

Get 1:1 Help Now