check if value is too big

Hi,

if we have table :

  1. user_limits:

user,

max_value

and table:

user_orders

user,

order_value

How we can compare order_value with max_value in user_order form .

I made something like this :

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

$sql5 = "SELECT max_value from tbl_sales where seller= (select username from tbl_user where id=’$curruser’) ";

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

$reader=$command->execute();

echo $reader;

but , result is always 1 .

I got something which is almost what i want , but i need to check max value against the dropdown list.

For example:

I have (in form ) field: sale_amount and dropdown list with 2 values evening and morning .

in my table tbl_sales i have max_value_evning and max_value_morning.

I need to validate sale_amount against max_value_evening if I choose evening …

For now I have this:

model :

public function getMaxsale()

{

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

$sql = "SELECT max_value from tbl_sales where seller= (select username from tbl_user where id=’$curruser’) ";

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

$maximum=$command->queryScalar();

return $maximum;

}

public function rules

array(‘sales’,‘numerical’,‘max’=>$this->getMaxsale())

anybody ?