如何在条件满足php时使用循环计算表行并执行代码

table

id,name,status
1   a    3
2   b    3
3   c    3

i have multiple rows in my table.

when i click submit button it check all rows if status of all rows is 4 then i put save condition else it runs another code.

i need to count rows of my table suppose their are 2 rows with status==3 then my forloop count rows and if all the 2 rows being status ==4 then create save logic..

Please help me to implement

below is my code..but it is not working for me..

$cond = array('OrderDetail.order_id'=>trim($this->requestData['orderId'])); 
$orderData = $this->OrderDetail->find('all',array('conditions'=>$cond));
$numData = sizeof($orderData);
$count=1;
foreach ($orderData as $value) {
    if($value['OrderDetail']['status'] > 3 && $value['OrderDetail']['status']!=5){
        if($numData == $count) {
            // if condition meets and all the rows of table have status==4 then 
            // save logic here
            // }
        }
        $count= $count+1;
    } 

You can simply do this:

 $cond = array('OrderDetail.order_id'=>trim($this->requestData['orderId'])); 
 // condition for status not equal to 4
 $conditionForStatus = array(
                       'OrderDetail.status !='=>4,
                       // 'OrderDetail.order_id'=>trim($this->requestData['orderId'])
                       );

 $orderData = $this->OrderDetail->find('all',array('conditions'=>$cond));

 // find count of record where status is not equal to 4
 $countOfStatus = $this->OrderDetail->find('count',array('conditions'=>$conditionForStatus ));
 if(!empty($orderData) && $countOfStatus == 0) {
    // your save logic here
 }

You just need some records in table but having status 4 only. Am i right ?