Saturday, May 31, 2014

Routing issue with named params

Hi,

We have several mobile apps that use the url structure /api/[search|facets]/type:[bar|foo|ra|sim].  
In a previous version this was simple to route  /:controller/:action/*  

This got to be unwieldy because of the amount of processing it took to retrieve information for the different types.

In our migration to cake 2.x, our new structure is bar extends api, foo extends api, ra extends api, etc.

This has worked really well, letting us extract the functions for foo into it's own controller, etc.

The problem is routing this.  I can't figure out how to route the controllers based on the named param 'type'.

Is there any way to extract the named param 'type', and pass that value into :controller using standard cake routing, or will I have to go to a custom route extension, similar to the :slugs example?


Thanks for looking at this!
Lee

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Friday, May 30, 2014

User table foreign key confusion

Hi,
I am confused about how the User table is linked to other tables.
To keep things simple I have a working version of a linked cakephp/mysql that can display ,add,edit records.

I add in security with a admin role who can see every page.
Everything is OK but I will need to add users with access to only somethings.

I have these tables

teachers
student
teacher-student (tutor sessions)
User

The question how do I link the User to the students,techers table as the user table seems to be a special case?
Would I need a user_id in these 2 tables and the user has foreign keys of teacher_id and student_id?
What about admin roles who can see all pages as they dont need a teacher or student id?
Or dont I bother linking tables as User table is a special case?

Do I need to set up a teachers table with id and also a user_id which is the same thing?

In cakephp  I link like this for example.

class User extends AppModel {
   
     public $hasOne = array('Teacher','Student');
  


class Teacher extends AppModel
{
   
    public $hasOne = 'User';


--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Auth returning true always

$data = array('username' => 'test', 'password' => 'test');
if($this->Auth->login($data)) return true;
else return false;

it returns true every time no matter what the values are for username and password

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

CakeResponse force zip download

i'm trying to force a .zip archive to download. I used as shown in the manual: $this->response->file($path . DS . $zip_name . '.zip', array('download' => true, 'name' => $zip_name)); return $this->response;

but instead of download, my browser keep showing strange characters. Seems that the headers are not correct...can someone help me with that because i didn't find anything useful in the cakebook? Thanks in advance. Fabio.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Extending FormHelper causes error in it

I want to extend the FormHelper and used this part of a method's code to be called in the view.
$out = parent::input($fieldName, $opts);
return parent::output($out);

Error: Call to a member function useTag() on a non-object 
File: ...lib/Cake/View/Helper/FormHelper.php 
Line: 861

the label method 
return $this->Html->useTag('label', $labelFor, $options, $text);

cakephp version 2.5.1

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: redirect not working

Although  the above fixed it , the issue remains the below code didnt work as expected, in fact it doesnt work. why?

class AppController extends Controller {
   
 public $components = array(
    'Session',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
        'logoutRedirect' => array(
            'controller' => 'users',
            'action' => 'login'
           
        ),
        'authorize' => array('Controller') // Added this line
    )
);

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: redirect not working

This solved the problem as I need to specify the redirect in the login
I also tried in the beforefilter without success

public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
           return $this->redirect(array('controller' => 'posts','action' => 'index'));
            //return $this->redirect($this->Auth->redirect());
        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Thursday, May 29, 2014

redirect not working

Hi,
I am following this tutorial below and I dont get an error but what happens is that when i login
I get redirected to the wrong place, explained below

cakephp/posts/index   -correct and I get redirected here sometimes
cakephp/   - other times I get redirected here with same login name

 
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html


class AppController extends Controller {
   
 public $components = array(
    'Session',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
        'logoutRedirect' => array(
            'controller' => 'pages',
            'action' => 'display',
            'home'
        ),
        'authorize' => array('Controller') // Added this line
    )
);
///
class UsersController extends AppController
{
public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
            return $this->redirect($this->Auth->redirect());
        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}



Connect with us: 

    

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: cant login

This the view I cant get out of

<div class="users form">
<?php echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('User'); ?>
    <fieldset>
        <legend>
            <?php echo __('!! Please enter your username and password'); ?>
        </legend>
        <?php echo $this->Form->input('username');
        echo $this->Form->input('password');
    ?>
    </fieldset>
<?php echo $this->Form->end(__('Login')); ?>
</div>



Connect with us: 

    

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

cant login

Hi,

I am learning how cakePHP does logins from this long example
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

I copied all the code in the files and there is a few files here.
Anyway I have 2 questions from that link

1) I cant get anything to login. I dont get an error but at the login screen I cant login with anything and also I go to add where I add a user and I get redirected back to the login screen.

I get from the login scren "You are not authorized to access that location".


2) is the below code required in the User.php file as i didnt include this App::uses
// app/Model/User.php    App::uses('AppModel', 'Model');  App::uses('SimplePasswordHasher', 'Controller/Component/Auth');



Connect with us: 

    

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Update field in associated model???

You forgot to say Happy Coding!

On Sunday, 11 December 2011 19:58:23 UTC-8, Geoff Douglas wrote:
I am not sure about any one else... but for me I normally have the id from either passing it in, or having it from related data. I must just not do a lot of "UPDATE"-ing. :)

I do use this for shell scripts more than web request type functions, because my shell scripts are generally more prone to do mass-updates. 

I will have to look around my code and see where I could optimize some of the updating methods. ???

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Order using Containable-Behaviour on deeper levels (>1)

Yehaw! It seems running Hash::Sort multiple times in the opposite direction one would do in a "normal" query solves exaclty this task :)

Hope, it doesnt have any drawbacks... ;)

Regards,
Frank

Am Donnerstag, 29. Mai 2014 12:55:57 UTC+2 schrieb LDSign:
Thanks. Ive already looked at the Hash::sort method.

But with that it is not possible to sort on multiple fields in priority. e.g. first "lastname" than "firstname" 

Or do I miss something?

Frank

Am Donnerstag, 29. Mai 2014 12:41:00 UTC+2 schrieb Jeremy Burns:
Look at Hash::sort - http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::sort

On 29 May 2014, at 11:28, LDSign <fr...@lamozik.de> wrote:

Hi

This was discussed several times on the inet - it seems that it is not possible to use an "orde"r on a deeper association connected with the containable behaviour, because the behaviour splits the query in several parts :(

Whats the best approach to make sorting on deeper levels work with containable?

Ive found an older behaviour called "Linkable" which promised to fill this gap, but unfortunatley it doesn't work with cake 2.5 :(

Thanks for your input!

Regards,
Frank

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Order using Containable-Behaviour on deeper levels (>1)

Ah. Not sure, but it looks like it sorts by a single key. Sorry.

On 29 May 2014, at 11:55, LDSign <frank@lamozik.de> wrote:

Thanks. Ive already looked at the Hash::sort method.

But with that it is not possible to sort on multiple fields in priority. e.g. first "lastname" than "firstname" 

Or do I miss something?

Frank

Am Donnerstag, 29. Mai 2014 12:41:00 UTC+2 schrieb Jeremy Burns:
Look at Hash::sort - http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::sort

On 29 May 2014, at 11:28, LDSign <fr...@lamozik.de> wrote:

Hi

This was discussed several times on the inet - it seems that it is not possible to use an "orde"r on a deeper association connected with the containable behaviour, because the behaviour splits the query in several parts :(

Whats the best approach to make sorting on deeper levels work with containable?

Ive found an older behaviour called "Linkable" which promised to fill this gap, but unfortunatley it doesn't work with cake 2.5 :(

Thanks for your input!

Regards,
Frank

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Order using Containable-Behaviour on deeper levels (>1)

Thanks. Ive already looked at the Hash::sort method.

But with that it is not possible to sort on multiple fields in priority. e.g. first "lastname" than "firstname" 

Or do I miss something?

Frank

Am Donnerstag, 29. Mai 2014 12:41:00 UTC+2 schrieb Jeremy Burns:
Look at Hash::sort - http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::sort

On 29 May 2014, at 11:28, LDSign <fr...@lamozik.de> wrote:

Hi

This was discussed several times on the inet - it seems that it is not possible to use an "orde"r on a deeper association connected with the containable behaviour, because the behaviour splits the query in several parts :(

Whats the best approach to make sorting on deeper levels work with containable?

Ive found an older behaviour called "Linkable" which promised to fill this gap, but unfortunatley it doesn't work with cake 2.5 :(

Thanks for your input!

Regards,
Frank

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Order using Containable-Behaviour on deeper levels (>1)

Look at Hash::sort - http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::sort

On 29 May 2014, at 11:28, LDSign <frank@lamozik.de> wrote:

Hi

This was discussed several times on the inet - it seems that it is not possible to use an "orde"r on a deeper association connected with the containable behaviour, because the behaviour splits the query in several parts :(

Whats the best approach to make sorting on deeper levels work with containable?

Ive found an older behaviour called "Linkable" which promised to fill this gap, but unfortunatley it doesn't work with cake 2.5 :(

Thanks for your input!

Regards,
Frank

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Order using Containable-Behaviour on deeper levels (>1)

Hi

This was discussed several times on the inet - it seems that it is not possible to use an "orde"r on a deeper association connected with the containable behaviour, because the behaviour splits the query in several parts :(

Whats the best approach to make sorting on deeper levels work with containable?

Ive found an older behaviour called "Linkable" which promised to fill this gap, but unfortunatley it doesn't work with cake 2.5 :(

Thanks for your input!

Regards,
Frank

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Wednesday, May 28, 2014

Re: cant edit but can add row cakephp

Hi

This fixed it as you said I mucked up the name.

 $this->Session->setFlash(

How can I say topic solved?





Connect with us: 

    

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: cant edit but can add row cakephp

Change :
$this->Tutorsession->setFlash
To
$this->Session->setFlash

Andras Kende
http://www.kende.com/


On Wednesday, May 28, 2014 7:10:55 AM UTC-7, jagguy wrote:
Hi,

In cakephp I cant edit a row from my mysql db but I can add a new row  on the same table without error.
Not sure what to do or how to debug this. The edittutorsession function is the problem

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'setFlash' at line 1

public function addtutorsession() {                   $te= $this->Tutorsession->Teacher->find('list', array('fields' =>  'Teacher.fullname'));       $this->set( 'te',$te);             $this->set( 'st',$this->Tutorsession->Student->find('list', array('fields' => array('Student.fullname') )));               if ($this->request->is('post')) {              $this->Tutorsession->create();              if ($this->Tutorsession->save($this->request->data)) {                  $this->Session->setFlash(__('Your post has been saved.'));                  return $this->redirect(array('action' => 'displayall'));              }              $this->Session->setFlash(__('Unable to add your post.'));          }    }      public function edittutorsession($id = null) {                      $te= $this->Tutorsession->Teacher->find('list', array('fields' =>  'Teacher.fullname'));       $this->set( 'te',$te);             $this->set( 'st',$this->Tutorsession->Student->find('list', array('fields' => array('Student.fullname') )));                     if (!$id) {          throw new NotFoundException(__('Invalid post'));      }        $post = $this->Tutorsession->findById($id);      if (!$post) {          throw new NotFoundException(__('Invalid post'));      }        if ($this->request->is(array('post', 'put'))) {          $this->Tutorsession->id = $id;          if ($this->Tutorsession->save($this->request->data)) {              $this->Tutorsession->setFlash(__('Your post has been updated.'));              return $this->redirect(array('action' => 'displayall'));          }          $this->Session->setFlash(__('Unable to update your post.'));      }        if (!$this->request->data) {          $this->request->data = $post;      }  }      ///////////////  view edittutorsession    <?php  echo $this->Form->create('Tutorsession');   echo $this->Form->input('teacher_id', array('options' => $te));   echo $this->Form->input('student_id', array('options' => $st));         echo $this->Form->input('subject');   //text      echo $this->Form->input('sessiondate',              array('label' => 'Session'));        echo $this->Form->input('sessiontime',              array('label' => 'time'));         echo $this->Form->input('available');    echo $this->Form->end('Save Post');  ?>





Connect with us: 

    

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Cake 2.5.1 Extremely Slow With MSSQL?

Hey guys,

I'm using the latest version of Cake (2.5.1) and am having a problem with extremely slow connections to a MSSQL server. A controller action that only has one simple select statement is taking an upwards of 50 seconds to complete. I don't think it's the select statement itself, I have a created an empty page that connects to MSSQL via PDO and executes the exact same statement and the result is instantaneous, so this leads me to believe it's a problem with the MSSQL data source packaged with Cake. If it was a driver or connection issue I would assume it would happen on the test page as well. Any ideas? I'm on PHP 5.3.x and am connecting to SQL Server 2008 R2.

Jordan

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

RE: cant edit but can add row cakephp

Not trying to interrupt the answer,

 

Just looking at the code and any future developer if you left the project….

 

Name the $vars

 

$t means? Teacher, call it teacher…..

 

$st? 1 date away from std?

 

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of Jeremy Burns : Class Outfit
Sent: Wednesday, May 28, 2014 11:47 AM
To: cake-php@googlegroups.com
Subject: Re: cant edit but can add row cakephp

 

What happens when you try the save? Does it create a new row instead or does it fail somewhere?

 

On 28 May 2014, at 15:10, jagguy <andrew@itfutures.edu.au> wrote:



Hi,

In cakephp I cant edit a row from my mysql db but I can add a new row  on the same table without error.
Not sure what to do or how to debug this. The edittutorsession function is the problem

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'setFlash' at line 1

public function addtutorsession() {
    
     
    $te= $this->Tutorsession->Teacher->find('list', array('fields' =>  'Teacher.fullname'));
     $this->set( 'te',$te);
     
    $this->set( 'st',$this->Tutorsession->Student->find('list', array('fields' => array('Student.fullname') )));
 
   
     if ($this->request->is('post')) {
            $this->Tutorsession->create();
            if ($this->Tutorsession->save($this->request->data)) {
                $this->Session->setFlash(__('Your post has been saved.'));
                return $this->redirect(array('action' => 'displayall'));
            }
            $this->Session->setFlash(__('Unable to add your post.'));
        }
 
}
 
 
public function edittutorsession($id = null) {
    
        
    $te= $this->Tutorsession->Teacher->find('list', array('fields' =>  'Teacher.fullname'));
     $this->set( 'te',$te);
     
    $this->set( 'st',$this->Tutorsession->Student->find('list', array('fields' => array('Student.fullname') )));
 
    
    
    if (!$id) {
        throw new NotFoundException(__('Invalid post'));
    }
 
    $post = $this->Tutorsession->findById($id);
    if (!$post) {
        throw new NotFoundException(__('Invalid post'));
    }
 
    if ($this->request->is(array('post', 'put'))) {
        $this->Tutorsession->id = $id;
        if ($this->Tutorsession->save($this->request->data)) {
            $this->Tutorsession->setFlash(__('Your post has been updated.'));
            return $this->redirect(array('action' => 'displayall'));
        }
        $this->Session->setFlash(__('Unable to update your post.'));
    }
 
    if (!$this->request->data) {
        $this->request->data = $post;
    }
}
 
 
///////////////
view edittutorsession
 
<?php
echo $this->Form->create('Tutorsession');
 echo $this->Form->input('teacher_id', array('options' => $te));
 echo $this->Form->input('student_id', array('options' => $st));
 
     echo $this->Form->input('subject');   //text
    echo $this->Form->input('sessiondate', 
           array('label' => 'Session'));  
    echo $this->Form->input('sessiontime', 
           array('label' => 'time'));  
     echo $this->Form->input('available');  
echo $this->Form->end('Save Post');
?>

 


 

Connect with us: 

 

    

 

Please consider the environment before printing this email.

 

This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

 

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

 

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: cant edit but can add row cakephp

What happens when you try the save? Does it create a new row instead or does it fail somewhere?

On 28 May 2014, at 15:10, jagguy <andrew@itfutures.edu.au> wrote:

Hi,

In cakephp I cant edit a row from my mysql db but I can add a new row  on the same table without error.
Not sure what to do or how to debug this. The edittutorsession function is the problem

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'setFlash' at line 1

public function addtutorsession() {                   $te= $this->Tutorsession->Teacher->find('list', array('fields' =>  'Teacher.fullname'));       $this->set( 'te',$te);             $this->set( 'st',$this->Tutorsession->Student->find('list', array('fields' => array('Student.fullname') )));               if ($this->request->is('post')) {              $this->Tutorsession->create();              if ($this->Tutorsession->save($this->request->data)) {                  $this->Session->setFlash(__('Your post has been saved.'));                  return $this->redirect(array('action' => 'displayall'));              }              $this->Session->setFlash(__('Unable to add your post.'));          }    }      public function edittutorsession($id = null) {                      $te= $this->Tutorsession->Teacher->find('list', array('fields' =>  'Teacher.fullname'));       $this->set( 'te',$te);             $this->set( 'st',$this->Tutorsession->Student->find('list', array('fields' => array('Student.fullname') )));                     if (!$id) {          throw new NotFoundException(__('Invalid post'));      }        $post = $this->Tutorsession->findById($id);      if (!$post) {          throw new NotFoundException(__('Invalid post'));      }        if ($this->request->is(array('post', 'put'))) {          $this->Tutorsession->id = $id;          if ($this->Tutorsession->save($this->request->data)) {              $this->Tutorsession->setFlash(__('Your post has been updated.'));              return $this->redirect(array('action' => 'displayall'));          }          $this->Session->setFlash(__('Unable to update your post.'));      }        if (!$this->request->data) {          $this->request->data = $post;      }  }      ///////////////  view edittutorsession    <?php  echo $this->Form->create('Tutorsession');   echo $this->Form->input('teacher_id', array('options' => $te));   echo $this->Form->input('student_id', array('options' => $st));         echo $this->Form->input('subject');   //text      echo $this->Form->input('sessiondate',              array('label' => 'Session'));        echo $this->Form->input('sessiontime',              array('label' => 'time'));         echo $this->Form->input('available');    echo $this->Form->end('Save Post');  ?>





Connect with us: 

    

Please consider the environment before printing this email.
 
This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential,  may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of National Training and Solutions Provider Pty Ltd ABN 34 123 831 023, or any of its related entities. NTSP does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.