Solved

How to query MySQL database from folder outside CodeIgniter application folder

Posted on 2014-03-13
4
969 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 110

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 110

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 dynamically set the form action using jQuery.

688 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