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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:46:15+00:00 2026-06-08T10:46:15+00:00

Im breaking my head here. Hope you can see what’s the error. I’ve installed

  • 0

Im breaking my head here. Hope you can see what’s the error. I’ve installed PHPActiveRecord to CodeIgniter throught a spark and all works great except one thing. Let me show you some code.

This is my problematic controller.

Model Article.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Article extends ActiveRecord\Model
{
    static $belongs_to = array(
        array('category'),
        array('user')
    );

    public function updater($id, $new_info)
    {
            // look for the article
        $article = Article::find($id);

            // update modified fields
        $article->update_attributes($new_info);
        return true;
    }
}

And this is the part where it shows me an error. Relevant code in Controller articles.php

        // if validation went ok, we capture the form data.
        $new_info = array(
            'title'       => $this->input->post('title'),
            'text'        => $this->input->post('text'),
            'category_id' => $this->input->post('category_id'),
         );

        // send the $data to the model                          
        if(Article::updater($id, $new_info) == TRUE) {
            $this->toolbox->flasher(array('code' => '1', 'txt' => "Article was updated successfully."));
        } else {
            $this->toolbox->flasher(array('code' => '0', 'txt' => "Error. Article has not been updated."));
        }

        // send back to articles dashboard and flash proper message
        redirect('articles');

When i call Article::updater($id, $new_info), it display a big annoying error:

Fatal error: Call to a member function update_attributes() on a non-object

The weirdest thing, is that i have a controller called categories.php and model Categoy.php that has the same functionality (i copy pasted the categories functionality for the articles) and this time, doesn’t work.

I have different functions inside model Article.php and all of them work fine, im struggling with that Article::updater part.

Does somebody know for a way to proper update a row? Im using as stated at docs in PHP AR site and it’s giving me that error. Why it does say that is not an object? It’s supposed to be an object when i do $article = Article::find($id).

Maybe im not seeing something really easy. Too many hours in front of computer.

Thanks amigos.

  • 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-08T10:46:17+00:00Added an answer on June 8, 2026 at 10:46 am

    Function updater needs to be marked static, and it should handle the error condition when $id is bad.

    public static function updater($id, $new_info)
    {
            // look for the article
        $article = Article::find($id);
        if ($article === null)
            return false;
    
            // update modified fields
        $article->update_attributes($new_info);
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently breaking my head on a 1452 error (using Symfony2 with doctrine). Here
I have been breaking my head over this hope it's possible declare @locationType varchar(50);
I am breaking my head why the simplest thing is not working. All I
I have been breaking my head for 3 hours now and I can't figure
I have been breaking my head trying to get this working but I can't
I hope someone can help me with the following scenario because I'm breaking my
I've been breaking my head on this easy validation and I can't get it
I'm breaking my head over this code: <html> <head> <title>Westpop</title> <link rel=stylesheet href=opmaak.css> </head>
I'm breaking my head over this one. I'm kind of new in android development.
I'm breaking my head trying to call a js function from a button element

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.