Yii Framework Forum: AddBetweenCondition - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

AddBetweenCondition trouble with AddBetweenCondition Rate Topic: -----

#1 User is offline   kay 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 14-July 11

Posted 12 May 2012 - 03:21 AM

mas bro
mohon bantuan nya .

public function actionCari()
	{
		
		$model=new Datarek;
                
                
                if(isset($_POST['Datarek']))
		{
			$model->attributes=$_POST['Datarek'];
                        //var_dump($_POST['Datarek']);
                        $nama = $_POST['Datarek']['nama'];
                        $bank = $_POST['Datarek']['bank'];
                        $tgl1 = $_post['Datarek']['tanggal'];
                        $tgl2 = $_post['Datarek']['tanggal_akhir'];
		}
                $criteria = new CDbCriteria;
                $criteria->AddSearchCondition('nama',$nama);
                $criteria->AddSearchCondition('bank',$bank);
                $criteria->AddBetweenCondition(array('tanggal', $tgl1 ,$tgl2 ,'AND'));
                
                
                
                $dataProvider=new CActiveDataProvider('Datarek', array(
                    'criteria'=>$criteria,
                    
                )); 
                
        print_r($dataProvider);
               
              
		$this->render('cari',array(
			'model'=>$model,
                        'dataProvider'=>$dataProvider,
		));
	}


tanggal bertype datetime
tp begitu variable nya diisi function search ga jalan ya

need Help

Regards

Arif
0

#2 User is offline   ahmadroni 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 250
  • Joined: 14-June 09
  • Location:Yogyakarta-Indonesia

Posted 24 May 2012 - 12:39 AM

coba seperti gan....

public function actionCari()
{
	$model=new Datarek;
	if(isset($_POST['Datarek']))
	{
			$model->attributes=$_POST['Datarek'];
			//var_dump($_POST['Datarek']);
			$nama = $_POST['Datarek']['nama'];
			$bank = $_POST['Datarek']['bank'];
			$tgl1 = $_post['Datarek']['tanggal'];
			$tgl2 = $_post['Datarek']['tanggal_akhir'];
	}
	$criteria = new CDbCriteria(array(
		'condition'=>'nama=:vnama AND bank=:vbank AND tanggal BETWEEN :vtgl1 AND :vtgl2',
		'params'=>array(
			':vnama'=>$nama,
			':vbank'=>$bank,
			':vtgl1'=>strtr($tgl1,array('%'=>'\%', '_'=>'\_', '\\'=>'\\\\')),
			':vtgl2'=>strtr($tgl2,array('%'=>'\%', '_'=>'\_', '\\'=>'\\\\')),
		),
	));
	
	$dataProvider=new CActiveDataProvider('Datarek', array(
		'criteria'=>$criteria,
	)); 
	
	$this->render('cari',array(
		'model'=>$model,
		'dataProvider'=>$dataProvider,
	));
}



semoga berhasil..!
jangan lupa cendolnya ya
Hospital Cost Management System and
Hospital Management Information System
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users