On Thu, Dec 23, 2010 at 8:38 AM, Dan <[email protected]> wrote: > Here is some code: > > Model: > class Project extends AppModel { > var $name = 'Project'; > var $primaryKey = 'project_id'; > > > function customFunction($id=0){ > $sql = "custom sql... where project_id = ?"; > $params = array( customValidation($id) ); > return $this->query($sql, $params, false); > } > } > > Controller: > class ProjectsController extends AppController { > var $name = 'Projects'; > > function test($id=0){ > $this->data = $this->Project->testByID($id); > } > } > > View: > echo $form->create("Project"); > echo $form->input('project_name'); > echo $form->end(); > > ISSUE: > > The controller's action with the custom SQL doesn't populate the form. > I figured out that It's due to the array not being in the proper > format: > > Custom query: Array ( [0] => Array (...) > CakePHP built in actions (ie. read() ): Array ( [Project] => Array > (...) > > Is there a way to have the custom SQL be returned in the proper format > and populate the form?
You could build the array yourself based on the result then return that from your model. Or, you could use Cake's find() instead. If there's something specific keeping you from doing that, perhaps there's asimpler workaround than using query(). Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
