Integrity constraint violation

Hi,

I was tring some things on my app, and after repeat same test some times i got a error that i dont know what mean

Heres the call:


User::myDoPayment("10.00", 0, "3X485379AE095940A")


	public static function myDoPayment($amount, $paywith = 0, $token = NULL)

	{

		$userid = Yii::app()->user->id;

		

		// User

		$sql = 'UPDATE '.self::tableName().' SET money = money+:amount, moneydeposited = moneydeposited+:amount WHERE id = :userid LIMIT 1';

		$command = Yii::app()->db->createCommand($sql);

		$command->bindParam(":userid",$userid,PDO::PARAM_INT);

		$command->bindParam(":amount",$amount,PDO::PARAM_STR);

		$command->execute();

		

		// History Payment

		$sql = 'INSERT INTO `historypayment` (userid, amount, paywith, token) VALUES (:userid, :amount, :paywith, :token)';

		$command = Yii::app()->db->createCommand($sql);

		$command->bindParam(":userid",$userid,PDO::PARAM_INT);

		$command->bindParam(":amount",$amount,PDO::PARAM_STR);

		$command->bindParam(":paywith",$paywith,PDO::PARAM_STR);

		$command->bindParam(":token",$token,PDO::PARAM_STR);

		$command->execute();

		

		// Site Stats

		$sql = 'UPDATE sitestat SET totalpaid = totalpaid+:amount';

		$command = Yii::app()->db->createCommand($sql);

		$command->bindParam(":amount",$amount,PDO::PARAM_STR);

		$command->execute();

	}



EDIT1

after call same function again same error happen

why?

EDIT2

my manual insert in phpmyadmin shows same error…

Thanks

Seems like you in the db, defined historypayment.id (instead of historypayment.userid) as foreign key to user.id.

/Tommy

nevermind

i have a relation set on id instead userid …

my fault

it was now solved

thanks please delete topic