Hello guys! I am fairy new to yii. So, i have a CActiveForm for bidding on some products. Say i have one product that is named package3 and i am receiving bids for it. I want every bid for that package to be higher than the last made. How can i do that?
My table is named Bids an its columns are:
Please put custom validation in Model - Bids
// get Higher Bid
// compare higher bids with $this->bid
// return error or true depends on validation
Hello again, thanks for your reply.
Can you be more specific about the customValidation function?
How can i get the highest bid from the database?
what i have in mind is something like:
//get all the records of the same packageID
//find the highest bid from these records
//compare highest bid with $this->bid
//return error etc
but i am not sure how to make the first two parts of the function. i have tried a lot of things but nothing worked…
I think that i managed to do it.
Here is my function:
$Criteria = new CDbCriteria();
$Criteria->condition = "packageID = $packid";
$Criteria->order = "bid DESC";
$products = Bids::model()->findAll($Criteria);
foreach ($products as $value)
$this->addError('bid', 'some error');
Is it ok? i am not sure.