コード例 #1
0
ファイル: Controller.php プロジェクト: Rajagunasekaran/BACKUP
    public function updateOrderAutoId($newId)
    {
        list($year, $month, $id) = explode("/", $newId);
        $tmpType = substr($id, 0, 3);
        $forwhat = '';
        switch(strtolower($tmpType))
        {
            case strtolower(Helper::CONST_qotid_static_str):
                $forwhat = Helper::CONST_Quote;
                break;
            case strtolower(Helper::CONST_odrid_static_str):
                $forwhat = Helper::CONST_Order;
                break;
            case strtolower(Helper::CONST_invid_static_str):
                $forwhat = Helper::CONST_Invoice;
                break;
        }
        $lastId = substr($id, strlen($tmpType));
        
        $condition = 'forwhat="' . $forwhat . '"';
        $condition .= ' AND foryear = ' . $year;
        $condition .= ' AND formonth = ' . $month;

        $criteria = new CDbCriteria;
        $criteria->condition = $condition;
        $result = Idmaster::model()->findAll( $criteria );                
        if(count($result) > 0)
        {
            $idmastermodel = $result[0];
        }
        else
        {
            $idmastermodel = new Idmaster;
        }
        $idmastermodel->foryear = $year;
        $idmastermodel->formonth = $month;
        $idmastermodel->forwhat = $forwhat;
        $idmastermodel->lastid = $lastId;
        
        return $idmastermodel->save();
    }
コード例 #2
0
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Idmaster::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}