Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] save function: a bug?!

[FIXED] save function: a bug?! 04 Jun 2012 15:26 #2477

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
Hi Admin,

on the save function in th MODEL:
	function save($data)
	{

		$row = $this->getTable();



		//Convert data from a stdClass
		if (get_class($data) == 'stdClass')
			$data = JArrayHelper::fromObject($data);

		//Current id if unspecified
		if ($data['id'] != null)
			$id = $data['id'];
		else if (($this->_id != null) && ($this->_id > 0))
			$id = $this->_id;

and more specific on the line:
if (get_class($data) == 'stdClass')

sometimes I get this error:

Warning: get_class() expects parameter 1 to be object, array given in ROOT\administrator\components\MYCOMPONENT\models\ITEM.php on line 233

I solved it in this way:
		if (is_object($data)) {
			//Convert data from a stdClass
			if (get_class($data) == 'stdClass')
				$data = JArrayHelper::fromObject($data);
		}
Last Edit: 25 Jul 2012 13:53 by admin.
The administrator has disabled public write access.

Re: save function: a bug?! 07 Jun 2012 05:30 #2496

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 35
  • Karma: 22
I 've never got error with save function, and have 7 different controllers ...
You have generate for 2.5 ?
The administrator has disabled public write access.

Re: save function: a bug?! 07 Jun 2012 10:00 #2501

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 985
  • Karma: 140
Will be solved in Cook 2.0
Coding is now a piece of cake
The administrator has disabled public write access.

Re: save function: a bug?! 26 Jun 2012 11:21 #2678

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 985
  • Karma: 140
Already fixed.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.086 seconds

Get Started