{"id":633,"date":"2014-01-21T11:37:49","date_gmt":"2014-01-21T11:37:49","guid":{"rendered":"http:\/\/thomas.w-p.me.uk\/blog\/?p=633"},"modified":"2014-01-21T11:37:49","modified_gmt":"2014-01-21T11:37:49","slug":"cakephp-personal-notes","status":"publish","type":"post","link":"https:\/\/thomas.w-p.me.uk\/blog\/2014\/01\/cakephp-personal-notes\/","title":{"rendered":"CakePHP Personal Notes"},"content":{"rendered":"<h2>Just links and things as I learn my way around CakePHP<\/h2>\n<p>https:\/\/github.com\/mcurry\/cakephp_static_user &#8211; didn&#8217;t work<\/p>\n<p>Realised that the acl plugin should be in app\/Plugin not \/plugins<br \/>\n<a href=\"http:\/\/book.cakephp.org\/2.0\/en\/plugins.html\">http:\/\/book.cakephp.org\/2.0\/en\/plugins.html<\/a><\/p>\n<p>Get data from another controller.<br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/9205540\/cakephp-how-to-retrieve-data-from-another-model-in-controller\">http:\/\/stackoverflow.com\/questions\/9205540\/cakephp-how-to-retrieve-data-from-another-model-in-controller<\/a><\/p>\n<pre class=\"lang:default decode:true\">$this-&gt;Result-&gt;Quiz-&gt;Question-&gt;find('count')<\/pre>\n<p>This found all the questions &#8211; not, as I first thought, the questions for that quiz.<\/p>\n<p><a href=\"http:\/\/devblog.springest.com\/how-to-find-related-data-in-habtm-models\/\">http:\/\/devblog.springest.com\/how-to-find-related-data-in-habtm-models\/<\/a><br \/>\nHelped me to<\/p>\n<pre class=\"lang:default decode:true\" title=\"In Model\/Quiz.php\">    public function number_of_questions()\r\n    {\r\n        $x = $this-&gt;Question-&gt;Quiz-&gt;find('all',array(\r\n            'conditions' =&gt; array(\r\n                'Quiz.id' =&gt; $this-&gt;id\r\n            )));\r\n        return(count($x[0]['Question']));        \r\n    }<\/pre>\n<p>Not sure what the 0 should be.\u00a0 Not very &#8220;CakePHP ish&#8221;. Then<\/p>\n<pre class=\"lang:default decode:true\" title=\"e.g. in another model or controller\">$this-&gt;Quiz-&gt;number_of_questions()<\/pre>\n<p>Uploads:<br \/>\nhttps:\/\/github.com\/blueimp\/jQuery-File-Upload<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just links and things as I learn my way around CakePHP https:\/\/github.com\/mcurry\/cakephp_static_user &#8211; didn&#8217;t work Realised that the acl plugin should be in app\/Plugin not \/plugins http:\/\/book.cakephp.org\/2.0\/en\/plugins.html Get data from another controller. http:\/\/stackoverflow.com\/questions\/9205540\/cakephp-how-to-retrieve-data-from-another-model-in-controller $this-&gt;Result-&gt;Quiz-&gt;Question-&gt;find(&#8216;count&#8217;) This found all the questions &#8211; not, as I first thought, the questions for that quiz. http:\/\/devblog.springest.com\/how-to-find-related-data-in-habtm-models\/ Helped me to public &hellip; <a href=\"https:\/\/thomas.w-p.me.uk\/blog\/2014\/01\/cakephp-personal-notes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">CakePHP Personal Notes<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[67],"class_list":["post-633","post","type-post","status-publish","format-standard","hentry","category-geekiness","tag-cakephp"],"_links":{"self":[{"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/posts\/633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/comments?post=633"}],"version-history":[{"count":5,"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/posts\/633\/revisions"}],"predecessor-version":[{"id":652,"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/posts\/633\/revisions\/652"}],"wp:attachment":[{"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/media?parent=633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/categories?post=633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thomas.w-p.me.uk\/blog\/wp-json\/wp\/v2\/tags?post=633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}