Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are using a <code>POST</code> request, while your controller action only works with a <code>GET</code> request:</p> <pre><code>if ($this-&gt;RequestHandler-&gt;isXml() &amp;&amp; $this-&gt;request-&gt;is('get')) { </code></pre> <p>This causes the variables not to be set in case of non XML/POST requests, resulting in the error your are receiving.</p> <p>Quick fix, allow <code>POST</code> requests too or use a <code>GET</code> request instead. Also I'd suggest to change your controller action so that it triggers proper exceptions in case the request doesn't fit the requirements. Here's an (untested) example how could look like:</p> <pre><code>public function getSchoolDetails() { // NOTE you don't necessarily need this, you could also force the type // of response using $this-&gt;RequestHandler-&gt;renderAs($this, 'xml'); if (!$this-&gt;RequestHandler-&gt;isXml()) { throw new BadRequestException(); } // NOTE as of CakePHP 2.3 you could use $this-&gt;request-&gt;onlyAllow('get'); // instead if (!$this-&gt;request-&gt;is('get')) { throw new MethodNotAllowedException(); } // NOTE use the request object instead of $_GET, it will safely return // null on non-existent parameters $id = $this-&gt;request-&gt;query('school_id'); // NOTE skip this in case you want to retrieve empty results instead if (!$this-&gt;School-&gt;exists($id)) { throw new NotFoundException(); } // NOTE you should use the containable behavior instead of this // unbinding orgy $this-&gt;School-&gt;unbindModel(array( 'hasMany' =&gt; array( 'Admin', 'Announcement', 'Batch', 'Class1', 'Event', 'Lunchmenu', 'Student', 'Timetable', 'SpecialInstruction' ), 'hasAndBelongsToMany' =&gt; array( 'Subject' ) )); $fields = array( 'School.id, School.school_name, School.logo, School.phone' ); $school = $this-&gt;School-&gt;find('first', array( 'fields' =&gt; $fields, 'conditions' =&gt; array( 'School.id' =&gt; $id ) )); $this-&gt;set(array( 'school' =&gt; $school, '_serialize' =&gt; array('school') )); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload