I am a Yii programer, not Zend, CI, CakePHP, ...), having 10 years of experiences of web project development. looking farword to discussing with you about my Yii/PHP skills or your present project
, my sky pe:hehbhehb1
sample code:
class MOfficeCampaignScore extends \yii\db\ActiveRecord
{
...
public static function getScoreByPicCategory($office_id, $pic_category, $date = null)
{
$start_date = \app\models\utils\OfficeCampaignUtils::getOfficeCampaignBeginDate($date);
$end_date = \app\models\utils\OfficeCampaignUtils::getOfficeCampaignEndDate($date);
$scores = self::find()->joinWith('campaignDetail')
->andWhere(['wx_office_campaign_detail.office_id' => $office_id])
->andWhere(['wx_office_campaign_detail.pic_category' => $pic_category])
->andWhere('wx_office_campaign_detail.created_time >= :start_time', [':start_time' => $start_date->format("Y-m-d H:i:s")])
->andWhere('wx_office_campaign_detail.created_time < :end_time', [':end_time' => $end_date->format("Y-m-d H:i:s")])
->all();
if (empty($scores)) {
return ['count' => 0, 'total' => 0];
}
$count = 0; $total = 0;
foreach ($scores as $score) {
$count++;
$total += $score->score;
}
return ['count' => $count, 'total' => $total];
}
...
}