Sign In!
|
New User?Signup Now!
|
Forgot password?
Source Code 4 you
Home
Create Forum Topic
Check WebSite Rank
Publish Articles
UV Web Booster
Contact
Forum Type
Search Engine
.Net C# VB F# VC++
MonoPoject
Java J2EE
Zand Php Cake Php
Oracle Database Server
Mysql Database Server
DB2 Database Server
MSSql Databse Server
Javascript Ajax
Html Xml Xhtml
C Programming
C++ Programming
D Programming
CGI Programming
Perl Programming
Cobol Programming
Pascal Programming
Ruby Programming
Drupal Programming
Automobile
Software Testing
Linux Unix Mac Sun OS
Embedded Systems
Mainframe
IC Microcircuit Chip
Electronics Electrical
Hardware Netwarking
SAP ERP
Logical Reasoning
Human Resources
Science
Agriculture
Accounting
History
Pharmaceutical
Other Topic
Zand Php Cake Php
Posted by :
park
"approved" field for a model
Hi,
Would like to add an "approved" field for a model. Users can only see
entries whose Model.approved = 1. Only in admin section can unapproved
entries be retrieved.
It's an existing site, so I don't want to rewrite conditions for all
find queries.
Is there a centralized method (presumably in Model) of achieving this?
Many thanks!
Posted by :
JamesF
Re : "approved" field for a model
ahh thats why we should be using fat models instead of fat
controllers.
the most direct way to achieve this would be to put it in each find
call.
the best way would be to set up a function in your model, lets call it
findApproved()
so in you model you put
function findApproved(){
$data = $this->find('all', array('conditions'=>array
('Model.approved'=>1,
more conditions etc etc)));
return $data;
}
in your controller just put
$this->Model->findApproved() in place of those old rusty controller
find calls.
If you have the better reply, then send it to us. We will display your reply after the approval.
Name :
Email Id :
Reply :