Cannot insert into database table

Cannot insert into database table

by Jerin Das -
Number of replies: 3

Hi Team ,

We have developed a new custom activity for the course. Our activity name is "blogactivity".

Its created successfully.

While creating ( after fill the form ) the datas are not entred into database table.


function blogactivity_add_instance($blogactivity)

{

 $blogactivity1 = new stdClass();
 $blogactivity1->name= 'test';
 echo $id = $DB->insert_record('test',$blogactivity1);

  exit;

}

each time the 'id' is increased while testing but no data didn’t entered into table .

Please help us to go forward.


We have done purge caches many time but no result.


Thanks in advance.

Regards,

Jerin

Average of ratings: -
In reply to Jerin Das

Re: Cannot insert into database table

by Darko Miletić -

What is the name of your table? Judging by your code it seems to be [prefix]test.

echo $id = $DB->insert_record('put here name of the table', $blogactivity1);



In reply to Darko Miletić

Re: Cannot insert into database table

by Jerin Das -

Thanks Darko for your quick reply. My table name is 'mdl_test'.
I think the insertion occurred somewhere because the id showed as increased while echo the id .

But no data entered into the table. When we try to insert manually direct to table ,  the id should be one after the showed one.

We could not identify the issue.


sad


In reply to Jerin Das

Re: Cannot insert into database table

by Jerin Das -

Hi Team ,


The issue was solved. We forget to put 'return'. The issue was related to that.


Thanks for your support.


Regards,

Jerin