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 5947673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:59:50+00:00 2026-05-22T16:59:50+00:00

Are functions inside of models directly accessible by users? Can a user pass arguments

  • 0

Are functions inside of models directly accessible by users?
Can a user pass arguments directly to a function in a model? Or, do arguments have to be passed through php?

In otherwords:
I have a model called notifications and in there a function called get_notifs($user)… I use the controller to call the function like the get_notifs($_SESSION['user_id']) (which is encrypted). I don’t want someone to be able to call get_notifs() with anything but their $_session as a argument. What is the best solution?

  • Am I already okay?
  • Should I rename get_notifs() to
    _get_notifs()?
  • Should I check the
    $_SESSION['user_id'] in the method
    itself?
  • Or, is there another better solution

    than any of these?

I have a controller: ajax.php which loads the model notification

    function __construct()
        {
        parent::__construct();
            $this->load->helper('url');
            $this->load->library('tank_auth');
            $this->load->model('notification');
            $this->load->model('search');
        }
function get_notifs()
    {
    $me = $this->session->userdata('user_id');
    if ($e = $this->notification->get_notif($me))
    {
 ...........
    }           
    else{
        echo "nothing was found wtf?";
    }

…………………………………………………
model: notification.php

function get_notifs($user){
......
}
  • 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-05-22T16:59:50+00:00Added an answer on May 22, 2026 at 4:59 pm

    Your code is perfectly fine!

    • Am I already okay?
      • I Think so
    • Should I rename get_notifs() to _get_notifs()?
      • No, it’s a public method so no need to make it look private.
    • Should I check the $_SESSION['user_id'] in the method itself?
      • No, this is the controller’s job
    • Or, is there another better solution than any of these?
      • You only need a solution to a problem, and i don’t see a problem here

    it sounds liek your application may be used by people other then yourself, i.e the public developers, why would you want enforce developers to code things your way, that’s going to make them upset at your application.

    CI Only routes requests to a controller, the user cannot access a model or library or any other class, the route goes like so: /controller/method/param

    the first segment will only ever load a controller file, the second will call the method in the param, passing any other variables such as param to that method.
    enter image description here
    Source: http://codeigniter.com/user_guide/overview/appflow.html

    As you can see from the flow chart above, only the controller has access to the model’s

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

Sidebar

Related Questions

I have a function that is often called inside of other functions, and I'd
I have made a function that connects to a models 'pre_save' signal. Inside the
I created a new model class as my_model.php inside /models folder, and a function
I have a couple of functions inside a class that essentially do the same
I am building a common function library but the functions inside need to reference
I know that javascript, for example supports functions inside of functions, like so: function
I have seen member functions programed both inside of the class they belong to
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside
I have Django model that looks like this: class Categories(models.Model): Model for storing the
I have multiple divs and I'm attempting to do a function when a user

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.