Ich habe ein Projekt whith diese Struktur in Controller-Ordner:Laden Sie ein Modell in Codeigniter 3.0.3
- places.php
- users.php
- items.php
- ...
Und in meinen Modellen Ordner:
- Place.php (der Name im Inneren ist Platz Klasse Active \ Modell erweitert)
- User.php
- ...
In meinem Controller places.php, wenn ich ein Modell, das ich habe zu ladende
$this->load->model('Place');
Und danach muss ich meine Methode so nennen: genau das zu tun
$this->place->get_all_places();
Es war Arbeit in meinem localhost aber nicht in meinem Server Ich überprüfe meine PHP-Version auf dem Server und es ist 5.6.
Wie kann ich das beheben?
Das ist mein Modell-Datei ist Place.php
class Place extends ActiveRecord\Model
{
static $table_name = 'places';
static $has_many = array(
);
public function get_all_places()
{
return true;
}
}
Das ist mein Controller Datei places.php ist
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Places extends MY_Controller {
function __construct()
{
parent::__construct();
if($this->user){
$access = TRUE;
}else{
redirect('login');
}
}
function index()
{
$this->content_view = 'places/all';
}
function get_places(){
$this->theme_view = '';
$this->load->model('Place');
$this->place->get_all_places();
}
}
Und der Fehler es war, dass:
Unable to locate the model you have specified: place
try '$ this-> Place-> get_all_places()' – Phiter
Ich habe versucht, aber nicht funktioniert. Es scheint, als ob man das Modell nicht lädt. Die Fehlermeldung Ich bekomme es: Das angegebene Modell kann nicht gefunden werden: place –
Fügen Sie mehr von Ihrem Controller und Modellcode hinzu, es ist schwierig, das Problem auf diese Weise zu finden. – Phiter