Created
December 23, 2011 10:02
-
-
Save v9n/1513776 to your computer and use it in GitHub Desktop.
get playlist and schedule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Model_Schedule_Detail extends Sprig { | |
| protected function _init() { | |
| $this->_fields += array( | |
| 'id' => new Sprig_Field_Auto, | |
| 'schedule' => new Sprig_Field_BelongsTo(array( | |
| 'model' => 'schedule', | |
| 'column' => 'schedule_id', | |
| )), | |
| 'playlist' => new Sprig_Field_BelongsTo(array( | |
| 'model' => 'playlist', | |
| 'column' => 'playlist_id', | |
| )), | |
| ); | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //.. | |
| if (count($playlists) > 0) { | |
| $json = array('page' => $param['page'], 'total' => $total, 'rows' => array()); | |
| foreach ($playlists as $key => $playlist) { | |
| $json['total']++; | |
| $schedule_name = array(); | |
| foreach (Sprig::factory('schedule_detail', array('playlist' => $playlist->id))->load(NULL, false) as $k=>$v) { | |
| $schedule_name[] = $v->schedule->load()->name; | |
| } | |
| $json['rows'][] = array('id' => $playlist->id, 'cell' => array($key+1, $playlist->name, $playlist->template_id->load()->name, $schedule_name, $playlist->user_id->load()->username)); | |
| } | |
| return $json; | |
| } | |
| //.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment