vendredi 5 août 2016

If statement strange behaviour

So my statement looks like this

if($id != null) {
        $product = $this->Products->find()->where(['Products.id' => $id])->contain(['Sizes', 'Images', 'Reviews'])->first();
    }

    if($product['id'] === null || $id === null) {
        $this->Flash->error('This product dont exist');
        return $this->redirect('/products');
    }

after executing it for the for the first time with good $product['id'] and $id everthing goes well, but after refresh of the same site this line get executed

$this->Flash->error('This product dont exist');

but the rest of the statement dont. app is on cakephp 3.x

spierdoliło sie na amen

Aucun commentaire:

Enregistrer un commentaire