2

Hello everyone i have developed an application in cakephp 2.x framework.I have written a code for update & save into database using following code:

public function editpackage($id=null)
{
    $this->layout='dashboard';
    $this->loadModel('Survay');
    if (!$id) {
        throw new NotFoundException(__('Your request is invalid'));
    }

    $get_survay_id = $this->Survay->findById($id);
    if (!$get_survay_id) {
        throw new NotFoundException(__('Your request is invalid'));
    }  

    if ($this->request->is(array('post', 'put'))) {
        $this->Survay->id = $id;
        $this->request->data['Survay']['modifydate']=DboSource::expression('NOW()');
        if ($this->Survay->save($this->request->data)) {
            $this->Session->setFlash('Your Survay is successfully  updated','default',array('class'=>'alert alert-success'));   
            return $this->redirect(array('controller'=>'Users','action'=>'detailspackage'));
        }
    }
    if (!$this->request->data) {
        $this->request->data = $get_survay_id;
    }
}

I am getting :

Non-static method DboSource::expression() should not be called statically, assuming $this from incompatible context
Inigo Flores
  • 4,461
  • 1
  • 15
  • 36
Sahadev
  • 1,368
  • 4
  • 18
  • 39
  • 1
    Take a look at [this](http://stackoverflow.com/questions/5864879/how-to-use-mysql-now-function-in-cakephp-for-date-fields) – skywalker Dec 02 '15 at 10:31
  • But why should i do this if i have added App::uses('DboSource', 'Model/DataSource'); at the top my my Controller file. This is also called statically – Sahadev Dec 02 '15 at 10:36
  • thanks budy i have solved my problem. – Sahadev Dec 02 '15 at 11:02

1 Answers1

0

This is because you are using PHP version 5.4 or higher in which E_STRICT has become part of E_ALL.

Option 1

You can remove ~E_STRICT from your error reporting by modifying your error config in app/Config/core.php:

Configure::write('Error', array(
    'handler' => 'ErrorHandler::handleError',
    'level' => E_ALL & ~E_STRICT & ~E_DEPRECATED,
    'trace' => true
));

Option 2

Instead of

DboSource::expression('NOW()');

You can call

$this->Model->getDataSource()->expression('NOW()');
Inigo Flores
  • 4,461
  • 1
  • 15
  • 36