Let me clarify...

private function isActionable($id)
    {
        if($this->Session->read('Auth.User.role') == 'admin'){
                return true;
        }

        $post = $this->Period->find('first', array(
                'conditions' => array(
                        'id' => $id,
                        'user_id' => $this->Session->read('Auth.User.id')
                )
        ));

        return !empty($post);
    }


Even if I change 'id' => $id, to 'period_id' => $id, it doesn't fix
it. It has a new errors of:

1.Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column
'Period.id' in 'where clause'
2.SQL Query: SELECT COUNT(*) AS `count` FROM `periods` AS `Period`
WHERE `Period`.`id` = '53'

I'm using cake2.0


On Nov 29, 3:50 pm, GG <[email protected]> wrote:
> I know why it's not working, I just cannot figure out how to fix it.
>
> These are my errors:
> 1. Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id'
> in 'where clause'
> 2. SQL Query: SELECT `Period`.`period_id`, `Period`.`title`,
> `Period`.`created`, `Period`.`modified`, `Period`.`user_id` FROM
> `periods` AS `Period` WHERE `id` = '51' AND `user_id` = 1 LIMIT 1
>
> The query should be: .... WHERE 'period_id' = '51' AND 'user_id' = 1
> LIMIT 1
>
> I am doing the request from /periods/delete/51
>
> Here is my PeriodsController.php
>
> function delete($id) {
>     if (!$this->request->is('post')) {
>         throw new MethodNotAllowedException();
>     }
>
>     if($this->isActionable($id)){
>             if ($this->Period->delete($id)) {
>                 $this->Session->setFlash('Work successfully deleted.');
>                 $this->redirect(array('controller' => 'posts', 'action' =>
> 'index'));
>             }
>     } else {
>                     $this->Session->setFlash('You cannot delete that post.');
>                     $this->redirect(array('controller' => 'posts', 'action' =>
> 'index'));
>     }
>     }
>
> This is in my view Students/index.ctp:
>
> $this->Form->postLink(
>                     'Delete Class',
>                     array('controller' => 'students', 'action' =>
> 'delete', $ps['Period']['period_id']),
>                     array('confirm' => 'Are you sure?'));
>
> -----------
>
> I'm sure it's something obvious, but I am having a real difficult time
> figuring it out. Thanks!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to