Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Warning: include(/var/www/web/frameworks/lithium/app/resources/tmp/cache/templates/template_views_layouts_default.html_886_1308416958_798.php) [function.include]: failed to open stream: No such file or directory in /var/www/web/frameworks/lithium/libraries/lithium/template/view/adapter/File.php on line 111
- Warning: include() [function.include]: Failed opening '/var/www/web/frameworks/lithium/app/resources/tmp/cache/templates/template_views_layouts_default.html_886_1308416958_798.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web/frameworks/lithium/libraries/lithium/template/view/adapter/File.php on line 111
- <?php
- namespace appmodels;
- class Posts extends lithiumdataModel {
- }
- ?>
- <?php
- namespace appcontrollers;
- use appmodelsPosts;
- class PostsController extends lithiumactionController {
- public function index() {
- $posts = Posts::all();
- return compact('posts');
- var_dump($posts);
- }
- public function add() {
- if($this->request->data) {
- $post = Posts::create($this->request->data);
- $success = $post->save();
- }
- return compact('success');
- }
- }
- ?>
- <?php foreach($posts as $post): ?>
- <article>
- <h1><?=$post->title ?></h1>
- <p><?=$post->body ?></p>
- </article>
- <?php endforeach; ?>
- <?=$this->form->create(); ?>
- <?=$this->form->field('title');?>
- <?=$this->form->field('body', array('type' => 'textarea'));?>
- <?=$this->form->submit('Add Post'); ?>
- <?=$this->form->end(); ?>
- <?php if ($success): ?>
- <p>Post Successfully Saved</p>
- <?php endif; ?>
- <?php
- namespace appmodels;
- class Posts extends lithiumdataModel {
- public $_meta = array('key' => 'postid');
- }
- ?>
- public function locations($companyid,$state=null) {
- /* removes null or false values with array_filter() */
- $conditions = array_filter(array('companyid' => $companyid, 'state' => $state));
- /* pass $conditions array to the Locations model, find all, order by city */
- $locations = Locations::find('all', array(
- 'conditions' => $conditions,
- 'order' => array('city' => 'ASC')
- ));
- return compact('locations');
- }
Add Comment
Please, Sign In to add comment