Welcome Guest, Not a member yet? Register   Sign In
Model with session only and without database
#1

(This post was last modified: 03-14-2024, 02:33 PM by StefanKittel.)

Hello,
I want to create one model with session only and without database.

The other models are needed for database operations.

The model should handle some informations in the session.

I think a model is more suitable than a controller

I remove everything in the model but a soon I call a function in it I get an error: "You must set the database table to be used with your query.".

I don't need any type of data behind this model.
I could put it in a controller and would be done. But it is wrong there.

So how to remove the database for this model only?

PHP Code:
<?php

namespace App\Models;

use 
CodeIgniter\Model;

class 
StateModel extends Model
{
    public function Init()
    {
        // Preload any models, libraries, etc, here.
        if (!isset($this->session))
        {
            $this->session = \Config\Services::session();
        }
    }

    public function GetLoginState()
    {
        return NO_SITE_SET;
    }

Reply
#2

Remove " extends Model”.
Reply
#3

(03-14-2024, 11:16 PM)kenjis Wrote: Remove " extends Model”.

Hello,
this worked. Than it should be renamed to "DBModel".
Reply




Theme © iAndrew 2016 - Forum software by © MyBB