Php 计算有多少付款是通过现金交付、贝宝、贝优等方式进行的。。。?

Php 计算有多少付款是通过现金交付、贝宝、贝优等方式进行的。。。?,php,mysql,yii,Php,Mysql,Yii,我想从订单表中计算现金交付、paypal、payu和CCAVINE的总数 订单表中有“付款方式”列。 在该列中有多个付款选项 我想数一数有多少付款通过现金交付,贝宝,贝优等。。。。(使用yii framwork时) 我如何做到这一点,使我的输出如下 cashondelivery = 50 paypal = 25 payu = 35 试试这个: $CodCount = Order::model()->countByAttributes(array(

我想从订单表中计算现金交付、paypal、payu和CCAVINE的总数

订单表中有“付款方式”列。 在该列中有多个付款选项

我想数一数有多少付款通过现金交付,贝宝,贝优等。。。。(使用yii framwork时)

我如何做到这一点,使我的输出如下

cashondelivery = 50
paypal =         25
payu =           35 
试试这个:

$CodCount = Order::model()->countByAttributes(array(
                'payment_method'=>'cashondelivery'
));
echo $CodCount; //returns number of cashondelivery
....//similarly for other payment types
或者

或者


您是否可以共享您在模型中为此编写的查询,或者您正在询问应该在模型中编写哪些代码?我正在询问应该在控制器中为我的questation编写哪些代码?在这种情况下,您应该共享从
var\u dump($list)获得的输出CDBEException CDbCommand未能执行SQL语句:SQLSTATE[42S22]:未找到列:1054“where子句”中的未知列“CASHONDEVERY”。执行的SQL语句是:SELECT*FROM
\u order
t
其中payment\u method=cashondelivery(D:\PHPServer\Amogam\yii\framework\db\CDbCommand.php:543)
$CodCount = Order::model()->countByAttributes(array(
                'payment_method'=>'cashondelivery'
));
echo $CodCount; //returns number of cashondelivery
....//similarly for other payment types
$CodCount = Order::model()->count("payment_method=:val", array("val" => "cashondelivery"));
echo $CodCount; //returns number of cashondelivery
....//similarly for other payment types
$dbCommand = Yii::app()->db->createCommand("
               SELECT payment_method,COUNT(*) as tot FROM `order` GROUP BY `payment_method`
            ");
$data = $dbCommand->queryAll();

foreach($data AS $val) {
        echo "Payment Method: ".$val["payment_method"]." total: ".$val["tot"]."<br/>";
    }
Payment Mode: cashondelivery total: 50
Payment Mode: paypal total: 25
Payment Mode: payu total: 35