Re: Output is not showing, but database is updated

2009-02-06 Thread Andras Kende


try to debug something like:

controller:

$tasks = $this->Task->find('all');
print_r($tasks);
$this->set('tasks', $tasks);

view:


Andras


On Feb 6, 2009, at 11:39 PM, abhishek wrote:

>
> I am writing a simple TASK application: with 1 model, 1 controller,and
> 2 views.
> In the application, you can add a task and it shows a list of all the
> tasks.
>
> my problem is I am not getting the output shown in the index view.
> Database is being updated fine, which means it is working I don't know
> why the data is not showing in the index view.
>
> Thanks a lot.
>
> My database:
> CREATE TABLE tasks(
>   id int(10) unsigned NOT NULL auto_increment,
>   title varchar(255) NOT NULL,
>   done tinyint(1) default NULL,
>   created datetime default NULL,
>   modified datetime default NULL,
>   PRIMARY KEY (id)
> );
>
> MODEL
>  class Task extends AppModel{
>   var $name = 'Task';
> }
> ?>
>
>
> THE CONTROLLER
>  class TasksController extends AppController{
>
>   var $name = 'Tasks';
>   var $helpers = array('Html', 'Form');
>   function index(){
>   $this->set('tasks', $this->Task->find('all'));
>
>   }
>
>function add(){
>if (!empty($this->data)){
>$this->Task->create();
>if ($this->Task->save($this->data)){
>$this->Session->setFlash('Task has been saved');
>$this->redirect(array('action'=>'index'),null, true);
>
>}else{
>$this->Session->setFlash('Task not saved. Try
> again.');
>}
>}
>
>}
> }
> ?>
>
> VIEW INDEX
>
> TASKS
> 
>   There are no tasks in this list
> 
>
>   
>   
>   Title
>   Status
>   Created
>   Modified
>   Actions
>   
>
>   
>   
>   
>   
>   
>
>   
>"Done";
>   else echo "Pending";
>   ?>
>   
>   
>   
>   
>   
>   
>   
>   
>
>   
>   
>   
>   
>
>
> 
> link('Add Task', array('action'=>'add')); ?>
>
>
> VIEW ADD:
> create('Task'); ?>
>
> 
>
>
>Add New Task
>
>echo $form->input('title');
>echo $form->input('done');
>?>
> 
> end('Add Task');?>
>
> link('List All Task', array('action'=>'index')); ?>
>
>
>
> my problem is I am not getting the output shown in the index view.
> Database is being updated. But it doesn't show in the view.
>
> >

Andras Kende
http://kende.com




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Output is not showing, but database is updated

2009-02-06 Thread Amit Badkas
What is the debug level? Set it to 2 if not and then look at SQL query

2009/2/7 abhishek 

>
> I am writing a simple TASK application: with 1 model, 1 controller,and
> 2 views.
> In the application, you can add a task and it shows a list of all the
> tasks.
>
> my problem is I am not getting the output shown in the index view.
> Database is being updated fine, which means it is working I don't know
> why the data is not showing in the index view.
>
> Thanks a lot.
>
> My database:
> CREATE TABLE tasks(
>id int(10) unsigned NOT NULL auto_increment,
>title varchar(255) NOT NULL,
>done tinyint(1) default NULL,
>created datetime default NULL,
>modified datetime default NULL,
>PRIMARY KEY (id)
> );
>
> MODEL
>  class Task extends AppModel{
>var $name = 'Task';
> }
> ?>
>
>
> THE CONTROLLER
>  class TasksController extends AppController{
>
>var $name = 'Tasks';
>var $helpers = array('Html', 'Form');
>function index(){
>$this->set('tasks', $this->Task->find('all'));
>
>}
>
>function add(){
>if (!empty($this->data)){
>$this->Task->create();
>if ($this->Task->save($this->data)){
>$this->Session->setFlash('Task has been saved');
>$this->redirect(array('action'=>'index'),null, true);
>
>}else{
>$this->Session->setFlash('Task not saved. Try
> again.');
>}
>}
>
>}
> }
> ?>
>
> VIEW INDEX
>
> TASKS
> 
>There are no tasks in this list
> 
>
>
>
>Title
>Status
>Created
>Modified
>Actions
>
>
>
>
>
>
>
>
>
> "Done";
>else echo "Pending";
>?>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 
> link('Add Task', array('action'=>'add')); ?>
>
>
> VIEW ADD:
> create('Task'); ?>
>
> 
>
>
>Add New Task
>
>echo $form->input('title');
>echo $form->input('done');
>?>
> 
> end('Add Task');?>
>
> link('List All Task', array('action'=>'index')); ?>
>
>
>
> my problem is I am not getting the output shown in the index view.
> Database is being updated. But it doesn't show in the view.
>
> >
>


-- 
Amit

http://amitrb.wordpress.com/
http://coppermine-gallery.net/
http://cheesecake-photoblog.org/
http://www.sanisoft.com/blog/author/amitbadkas

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Output is not showing, but database is updated

2009-02-06 Thread abhishek

I am writing a simple TASK application: with 1 model, 1 controller,and
2 views.
In the application, you can add a task and it shows a list of all the
tasks.

my problem is I am not getting the output shown in the index view.
Database is being updated fine, which means it is working I don't know
why the data is not showing in the index view.

Thanks a lot.

My database:
CREATE TABLE tasks(
id int(10) unsigned NOT NULL auto_increment,
title varchar(255) NOT NULL,
done tinyint(1) default NULL,
created datetime default NULL,
modified datetime default NULL,
PRIMARY KEY (id)
);

MODEL



THE CONTROLLER
set('tasks', $this->Task->find('all'));

}

function add(){
if (!empty($this->data)){
$this->Task->create();
if ($this->Task->save($this->data)){
$this->Session->setFlash('Task has been saved');
$this->redirect(array('action'=>'index'),null, true);

}else{
$this->Session->setFlash('Task not saved. Try
again.');
}
}

}
}
?>

VIEW INDEX

TASKS

There are no tasks in this list




Title
Status
Created
Modified
Actions


























link('Add Task', array('action'=>'add')); ?>


VIEW ADD:
create('Task'); ?>




Add New Task

input('title');
echo $form->input('done');
?>

end('Add Task');?>

link('List All Task', array('action'=>'index')); ?>



my problem is I am not getting the output shown in the index view.
Database is being updated. But it doesn't show in the view.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---