If you perform a var_dump of $name I bet it would be $name[0]['player'].
On Nov 19, 2012 3:52 PM, "kijciwoko" <adam.krupczynski@gmail.com> wrote:
-- Ok, sorry for newbie question, but I just don't get it and it drives me mad. Nothing works. This is my controller:
class EntriesController extends AppController
{
var $uses = array('Entry', 'FCPlayer');
function index()
{
}
function get_entries()
{
$this->set('data', $this->Entry->find('all'));
$this->layout = 'ajax';
}
function admin_index()
{
$this->set('fields', $this->Entry->find('all'));
}
function admin_add()
{
if (!empty($this->data))
{
if ($this->PEntry->save($this->data))
{
$this->Session->setFlash('new entry, happy days...: '.$this->data['Entry']['time'].', add next:', 'success');
$this->redirect(array('action' => 'add'));
}
}
$this->set('f_c_players', $this->FCPlayer->find('list'));
}
function admin_edit($id = null)
{
$this->Entry->id = $id;
if (!$id && empty($this->data))
{
$this->Entry->setFlash('Wrong Id!', 'failure');
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data))
{
if ($this->Entry->save($this->data))
{
$this->Session->setFlash('Edited.', 'success');
$this->redirect(array('action' => 'index'));
}
}
if (empty($this->data))
{
$this->data = $this->Entry->read(null, $id);
}
}
function admin_delete($id = null)
{
if (!$id)
{
$this->Session->setFlash('Wrong Id!', 'failure');
$this->redirect(array('action' => 'index'));
}
if ($this->Entry->delete($id))
{
/*************** What I need here is:
1. You have id of this entry which you're about to delete.
Find this record in database (table: entries)
and get me name of the player from same record but different column.
2. Ok, you hava a name. Look in another table (fc_players) for a record containing
this name you've just found.
3. Ok, found a record? Now look at the "news" column. There's an int.
If it's bigger then 1 just reduce and leave it there.
If it's equal 1 go ahead and delete whole record.
****************/
$this->Session->setFlash('Deleted.', 'success');
$this->redirect(array('action' => 'index'));
}
}
function admin_deleteAll()
{
if ($this->Entry->deleteAll('1 = 1'))
{
$this->Session->setFlash('All deleted.', 'success');
$this->redirect(array('action' => 'index'));
}
}
}
My problem is that apparently no matter what I do, my cake (1.3.4) doesn't want to cooperate. I've asked my question here: http://stackoverflow.com/questions/13443605/cakephp-sql-queries] but I don't think they can help me since I can't even format code on their website like civilized human being.
My guess is that something's wrong with sql statements but I can't be sure because for some reason when I ask google "hey, dude, how can I debug my CakePHP?" it responds "How the hell should I know?". Even if I go with $this->Entry->query it seems that my cake is too lazy to do anything (although $this->Session->setFlash('message','success'); seems to be working and when I try to send to my admin panel result of a query like in:
$name = $this->Entry->query("SELECT player FROM entries WHERE id = '" . $id . "'");$this->Session->setFlash($name,'success');
it shows blank message (and yes, i know it's not cake-efficient to do queries that way, I'm just that desperate)). I have no idea what else can I try. Any help?--
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.
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