Yii Framework Forum: Wrong Updating Table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Wrong Updating Table Rate Topic: -----

#1 User is offline   Trinh Duy Hung 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 26-October 12

Posted 19 February 2013 - 10:15 PM

Hello everyone!

In a view I use this snippet:
<?php 
	echo CHtml::ajaxSubmitButton (
	   ' ++ ',
	   array('/searchDriver/increasePoint'),
	   array(
	     'type'=>'POST',
	     'data' => array('id' => $someValue)
	   )			            
	);
?>

in searchDriverController I have an action like this:
        public function actionIncreasePoint()
	{	
	   $connection = yii::app()->db;
           $sql = "UPDATE xeom_driver SET driver_point = driver_point  + 1 WHERE driver_id = ".$_POST['id'].";";
           $command=$connection->createCommand($sql);
           $command->execute();

	}

The weird thing happens here is that: the value of driver_point is not increased by 1. In fact it's increased by 2.
I know that the sql is working. For example if I set driver_point to some value.

Has anybody faced this situation and have explanation ?

Thanks in advanced!
0

#2 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 21 February 2013 - 08:23 PM

If nothing else, I think you might have a security issue with that sql.
Other than that, are you using renderpartial? : http://www.yiiframew...rtial-conflict/

And what is this: "' ++ ',"?

I'm really not sure what this does in your app, but ++ typically increases a value by 1, but you do this in you sql as well... just wondering.

All the best :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users