Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:10:30+00:00 2026-06-17T16:10:30+00:00

I cannot find the error. I am trying to use the restserver of codeingniter:

  • 0

I cannot find the error.

I am trying to use the restserver of codeingniter: https://github.com/philsturgeon/codeigniter-restserver

Implemented it as describe in the installation of restserver.

For some reason I cannot query the database: In the browser i get the errormessage

A PHP Error was encountered
Severity: Notice
Message: Undefined property: Image::$db
Filename: core/Model.php
Line Number: 51

The error seems to be in the model when doing the $query, for some reason db is not correct?

Any ideas?

Following files did i implement to make the call on: http://www.test.com/index.php/image/index

Model: application/models/image_model.php

<?php if (  ! defined( 'BASEPATH')) exit( 'No direct script access allowed');
class Image_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }

    function getAll() {
        //$query = $this->db->get('images');    // Does not work. Active Record missing in libraries?
        $query = $this->db->query( 'SELECT * FROM images' );
        return $query->result(  );
    }
}
?>

Controller: application/controllers/image.php

<?php
require(APPPATH . 'libraries/REST_Controller.php');

class Image extends REST_Controller
{
    public function index_get()
    {
        $this->load->model( 'image_model');
        $images = $this->image_model->getAll();
        $this->response($images);
    }

    public function index_post()
    {
        // Create a new book
    }
}
?>

Config section database: application/config/database.php

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'foo';
$db['default']['password'] = 'bar';
$db['default']['database'] = 'testdrive';
$db['default']['dbdriver'] = 'mysql';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:10:30+00:00Added an answer on June 17, 2026 at 4:10 pm

    Did you autoload the database library by setting $autoload['libraries'] in application/config/autoload.php? If not you need to do this:

    Open your application/config/autoload.php and find:

    $autoload['libraries'] = array();
    

    And change it to:

    $autoload['libraries'] = array('database');
    

    If you do not want to use a database connection on every page request you can also load the database library manually my calling $this->load->database();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use JavaScriptSerializer in my application. I initially received Cannot find
I am trying to use randoop(automatic test generator for Java) and randoop cannot find
I am getting a Cannot Find Symbol error for rowData, and columnLabels. Is the
I get the following error: org.dbpedia.spotlight.exceptions.ConfigurationException: Cannot find spotter file ../dist/src/deb/control/data/usr/share/dbpedia-spotlight/spotter.dict at org.dbpedia.spotlight.model.SpotterConfiguration.<init>(SpotterConfiguration.java:54) at
I'm getting the following error when calling a stored procedure: Cannot find the object
I'am very new to google-apps-script. I encounter this error TypeError: Cannot find function getValue
I'm trying to use the new(ish) AS3 global error handling class. I am trying
I'm trying to use ios-cmake to generate Xcode project targeting iOS. However, it cannot
I'm trying to use Hibernate in my Spring application but i've got an error
I'm trying to use getServletContext().getRealPath( / ) , but I keep getting this error:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.