cakephp


CakePHP contain key issue


Hi i wrote contain on my model it effects only on first record and the rest of them
contains all the unnecessary records.
My Controller logic :
$findFiles['conditions']['Content.created_by'] = $curUser;
$findFiles['conditions']['KmpContent.is_approved'] = false;
$findFiles['conditions']['KmpContent.is_file'] = true;
$findFiles['contain'] = array('Parent' => array('SectionApprover' => array('Approver')));
$findFiles['recursive'] = 3;
$findFiles['fields'] = array('id', 'file_path', 'url_path', 'is_approved', 'name', 'created', 'approved_by','parent_id','display_text','is_active');
$fileData = $this->KmpContent->find('all', $findFiles);
The array Details are as follows
0 =>
array (
'KmpContent' =>
array (
'id' => '881',
'file_path' => '/uploads/test_file_for_multiple_approvers_backend_validations.docx',
'url_path' => '/uploads/test_file_for_multiple_approvers_backend_validations.docx',
'is_approved' => '0',
'name' => 'file_test_file_for_multiple_approvers_backend_validations.docx',
'created' => '2013-08-20 11:49:58',
'approved_by' => NULL,
'parent_id' => '143',
'display_text' => 'test file for multiple approvers',
'is_active' => '1',
),
'Parent' =>
array (
'id' => '143',
'name' => 'sct_Services.html',
'display_text' => 'Services',
'Parent' =>
array (
),
'Uploader' =>
array (
),
'SectionApprover' =>
array (
0 =>
array (
'id' => '104',
'kmp_content_id' => '143',
'approver_id' => '882',
'Approver' =>
array (
'id' => '882',
'first_name' => 'Prakasha',
'last_name' => 'Matte',
),
),
1 =>
array (
'id' => '256',
'kmp_content_id' => '143',
'approver_id' => '1168',
'Approver' =>
array (
'id' => '1168',
'first_name' => 'Rima Roy',
'last_name' => 'Chowdhury',
),
),
2 =>
array (
'id' => '257',
'kmp_content_id' => '143',
'approver_id' => '1171',
'Approver' =>
array (
'id' => '1171',
'first_name' => 'Durga Venkatesh',
'last_name' => 'Sambhani',
),
),
3 =>
array (
'id' => '258',
'kmp_content_id' => '143',
'approver_id' => '1172',
'Approver' =>
array (
'id' => '1172',
'first_name' => 'Gowtham Babu',
'last_name' => 'Tummala',
),
),
4 =>
array (
'id' => '259',
'kmp_content_id' => '143',
'approver_id' => '889',
'Approver' =>
array (
'id' => '889',
'first_name' => 'Sandeep',
'last_name' => 'Pathuri',
),
),
),
),
'SectionApprover' =>
array (
),
),
1 =>
array (
'KmpContent' =>
array (
'id' => '882',
'file_path' => '/uploads/test_file_for_ma_contentcontroller_save.txt',
'url_path' => '/uploads/test_file_for_ma_contentcontroller_save.txt',
'is_approved' => '0',
'name' => 'file_test_file_for_ma_contentcontroller_save.txt',
'created' => '2013-08-20 11:54:15',
'approved_by' => NULL,
'parent_id' => '28',
'display_text' => 'test file for MA',
'is_active' => '1',
),
'Parent' =>
array (
'id' => '28',
'name' => 'sct_domain.html',
'display_text' => 'Domains',
'Parent' =>
array (
),
'Uploader' =>
array (
),
'SectionApprover' =>
array (
0 =>
array (
'id' => '26',
'kmp_content_id' => '28',
'approver_id' => '467',
'KmpContent' =>
array (
'id' => '28',
'name' => 'sct_domain.html',
'description' => NULL,
'page_title' => 'IVV Knowledge Portal :: mckesson :: domain',
'display_logo_path' => '../images/domains.png',
'display_text' => 'Domains',
'top_logo_path' => '/mckesson_ban.jpg',
'top_logo_url' => 'http://www.mckesson.com/en_us/McKesson.com/',
'header_text' => 'Domains',
'header_desc' => NULL,
'header_logo_path' => '',
'is_section' => '1',
'url_path' => '/university/mckesson/domains.html',
'can_upload_files' => '1',
'is_file' => '0',
'file_path' => NULL,
'display_order' => '1',
'aco_path' => '',
'menu_name' => 'mckesson',
'view_path' => 'download_files',
'is_approved' => '1',
'parent_id' => '11',
'is_active' => '1',
'created' => '2013-06-22 21:18:27',
'created_by' => NULL,
'modified' => '2013-06-22 21:21:01',
'approved_by' => NULL,
),
'Approver' =>
array (
'id' => '467',
'first_name' => 'Nageswara Rao',
'last_name' => 'Menda',
),
),
),
),
'SectionApprover' =>
array (
),
),
I dont want the kmpContent in with in the sectionapprovers for all the records
What if you formatted the statement like
$fileData = $this->KmpContent->find('all', array(
'conditions' => array(
'KmpContent.created_by' => $curUser,
'KmpContent.is_approved' => false,
'KmpContent.is_file' => true,
),
'contain' => array(
'Parent' => array(
'SectionApprover' => array(
'Approver'
)
)
),
'recursive' => 3, // though you don't need to set recursive with contain
'fields' => array('id', 'file_path', 'url_path', 'is_approved', 'name', 'created', 'approved_by','parent_id','display_text','is_active')
));

Related Links

Facing a file permission error while running CakePHP in Ubuntu 10.4
cakephp plugin model/controller cache issue with main model/controller
select dropdown displays utf-8 characters but not displaying chinese characters
Render View from AppExceptionHandler
JsHelper is doing a POST request by submitting the 2nd time
something wrong with this find statment cakephp 1.3
Using routing for URLs with CakePHP Wizard Component
cakephp auth redirect and referrer
How to validate associated models
how to write this code with cakephp 1.3 html helper?
saving records with cakephp-mongo plugin
Why is CakePHP 1.3 Pagination ignoring my order?
Cakephp 2.0 URL Rewriting - Cityname needs to append before the controller and action?
cakephp 2 redirect url with hashtag
CakePHP Global slug router
why email component dont sent activation code to gmail?

Categories

HOME
twitter
xamarin
multithreading
cloud
netsuite
keras
openstack
mediawiki
pycharm
kde
path-finding
octobercms
getelementsbytagname
programming-languages
sqlite3
c#-2.0
jxls
gps
echarts
metatrader4
reveal.js
vb.net-2010
fallback
netflix
worldwind
after-effects
reactive-cocoa
text-rendering
nhibernate-envers
samoa
jtextfield
swiftlint
cloudhub
accessor
extjs5
language-agnostic
wpfdatagrid
rst2pdf
replaceall
kendo-datasource
microsoft-chart-controls
caret
openoffice.org
xmlreader
bower-install
devextreme
service-discovery
jna
android-fingerprint-api
graphenedb
dynamic-reports
android-mediaprojection
qwt
osx-mavericks
jquery-validate
clean-architecture
typescript1.8
powercli
tropo
svmlight
aurelia-validation
sqlclient
capacity
pearson
orthogonal
xcb
color-picker
azure-virtual-network
nsfilemanager
storekit
qgraphicsview
design-by-contract
two-factor-authentication
ios8-today-widget
separator
xna-4.0
ora-00900
collapse
cyclomatic-complexity
feedback
coveralls
tableau-online
method-parameters
appfabric-cache
rake-task
pick
tt-news
cdt
qcodo
titanium-modules
dml
dealloc
resty-gwt
openlaszlo
gnu-smalltalk
jsctypes
gwt-rpc
back-stack
eventlistener
selected
pvrtc
cisco-jtapi
first-responder
runas
twrequest
dbproviderfactories
appconkit
online-compilation
semantic-diff
pendrive
assembly-loading
gnustep
file-comparison
html-input
asp.net-mvc-areas
avatar
privilege
noscript
misv

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App