I'm looking for a way to read a single item from the database, I can pass it to the view rather easily, but reading it in the same controller is confounding me.
I've tried:
$title = $this->Project->read('title');
$title = $this->Project->find('first', array('fields' => array('Project.title'), 'conditions' => array('Project.id' => $id)));
$title = $this->Project->query("SELECT `title` FROM `Projects` WHERE `id`=$id");
All I'm trying to do is display a message that says "Hey you deleted this project" later I have
$this->Session->setFlash(__("Project $title deleted"));
However, when the message flashes all I see "Project Array deleted" with all three examples. I understand what it's doing... I just don't understand why... how do I select the actual "title" from the array, instead of the entire array?
Using CakePHP 2.x if it makes a difference in this instance.
-- All I'm trying to do is display a message that says "Hey you deleted this project" later I have
$this->Session->setFlash(__("Project $title deleted"));
However, when the message flashes all I see "Project Array deleted" with all three examples. I understand what it's doing... I just don't understand why... how do I select the actual "title" from the array, instead of the entire array?
Using CakePHP 2.x if it makes a difference in this instance.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment