CodeIgniter Forums

Full Version: Problem with my deleted_by & deleted_at using MY_Model
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi friends I am new to base model deleted_by & deleted_at is not functioning properly null value is updated can anybody help whats wrong in my code.

class Article_model extends MY_Model{
//should i kept it before OR after ?
public $after_delete = array( 'delete_timestamps' );
protected $soft_delete = TRUE;
//my column name is deleted_by such case still i have to mentioned or its optional
protected $deleted_by_key = 'deleted_by';

protected function delete_timestamps($article)
$article['deleted_at'] = date('Y-m-d H:i:s');
return $article;

class Test extends CI_Controller {

//error reported
A PHP Error was encountered
Severity: Warning
Message: Cannot use a scalar value as an array
Filename: models/article_model.php
Line Number: 51

//table strucure
CREATE TABLE `articles` (
 `body` text,
 `title` varchar(250) DEFAULT NULL,
 `created_at` datetime NOT NULL,
 `last_updated` datetime NOT NULL,
 `deleted_at` datetime NOT NULL,
 `deleted` tinyint(4) NOT NULL DEFAULT '0',
 `deleted_by` int(11) NOT NULL DEFAULT '0',
 PRIMARY KEY (`id`),
 FULLTEXT KEY `body` (`body`,`title`)
MY_Model doesn't exist in CodeIgniter unless you create it. Where did you find the MY_Model?
It's difficult to tell, but if line 51 is:

PHP Code:
$article['deleted_at'] = date('Y-m-d H:i:s'); 

Then the issue is that delete_timestamps() is not receiving an array (or PHP doesn't recognize it as an array).