facebook_credits_api:sample_cakephp_model_2
サンプル - cakephp - model(2)
<?php class CreditItem extends AppModel { var $name = 'CreditItem'; var $useDbConfig = 'credit'; var $useTable = 'credit_items'; var $validate = array( ); var $get_fields = array( 'CreditItem.id', 'CreditItem.title', 'CreditItem.description', 'CreditItem.image_url', 'CreditItem.product_url', 'CreditItem.price', 'CreditItem.cheer_point', ); public function get($item_id = null) { $params = array( 'fields' => $this->get_fields, 'order' => array('CreditItem.id'), ); if (!is_null($item_id)) { $con = array('conditions' => array("id" => $item_id)); $params = array_merge($params,$con); } $retVal = $this->find('all', $params); return $this->formatDate($retVal); } public function formatDate($params) { foreach ($params as $row) { $array[] = $row['CreditItem']; } $retVal = array('CreditItem' => $array); return $retVal; } }
facebook_credits_api/sample_cakephp_model_2.txt · 最終更新: 2014/03/06 07:12 by clownclown