Tutorial Yii Framework


(The Mentor) #81

Salam buat akang-akang semua,

Saya mau nanya mas,gimana cara hubungin form log in yang di my web application ke database & my sql ?

(saya make xampp mas)…

#thanks before


(Yulianto777) #82

dao tadi blum terjawab ? help me


(Devi Rachmawati) #83

mau nanya kenapa photo yg di upload ga masuk ke db ya?? klo ke folder images.a masuk, tapi reload browser.a munculnya Error 404

The requested page does not exist.

scriptnya ky gini:

public function actionCreate() {

$model = new Gallery;

if (isset($_POST[‘Gallery’])) {

$model->attributes = $_POST[‘Gallery’];

$model->photo = CUploadedFile::getInstance($model, ‘photo’);

if (!empty($model->photo)) {

$path = Yii::getPathOfAlias(‘webroot’) . Yii::app()->params->folder_gallery . $model->photo;

$path_thumb = Yii::getPathOfAlias(‘webroot’) . Yii::app()->params->folder_gallery_thumb . ‘thumb_’ . $model->photo;

$model->photo->saveAs($path);

$thumb = Yii::app()->phpThumb->create($path);

$thumb->resize(428, 428);

$thumb->save($path_thumb);

}

if ($model->save())

$this->redirect(array(‘view’, ‘id’ => $model->id));

}

$this->render(‘create’, array(

‘model’ => $model,

));

}

mohon bantuan semuanya :)

saya msh newbie,

o iyaa saya di viewnya tdk menggunakan CFormModel, apakah bisa???


(R Alfarizy) #84

permisi master master semua

ane bikin web, supaya bisa dijalankan di server tempat kita naro aplikasinya gmn yah ? apa aplikasi dan folder yii dijadiin satu semua ato gmn ?


(Edward Ongo) #85

ini contoh pake DAO

ini di modelnya :


    /*listing vendor*/

    public function listVendor()

    {

        $arrvendor = array();

                

        //loop through vendor first

        $connection=Yii::app()->db;

        

        $ssi_query = "select * from ssi_vendor order by vendor_id";

        $ssi_result = $connection->CreateCommand($ssi_query)->query();

        

        $i=1;

        foreach($ssi_result as $ssi_fetch)

        {

            $vid = $ssi_fetch["vendor_id"];

            $vname = $ssi_fetch["vendor_name"];

            

            // put in array

            $arrvendor[$i]["seq"]=$i;

            $arrvendor[$i]["id"]=$vid;

            $arrvendor[$i]["name"]=$vname;

            

            // get raw material code

            $item[] = $this->getRawName($ssi_fetch["vendor_raw_material_1_code"]);

            $item[] = $this->getRawName($ssi_fetch["vendor_raw_material_2_code"]);

            $item[] = $this->getRawName($ssi_fetch["vendor_raw_material_3_code"]);

            $item[] = $this->getRawName($ssi_fetch["vendor_raw_material_4_code"]);

            $item[] = $this->getRawName($ssi_fetch["vendor_raw_material_5_code"]);

            

            foreach($item as $k => $v)

            {

                if($v!=null)

                {

                    $items[]=$v;

                }

            }

            $nitem = implode(",", $items);

            $arrvendor[$i]["items"]=$nitem;

            

            unset($items);

            unset($nitem);

            unset($item);

            

            //get last shipment

            $shipment_date = $this->getLastShipment($ssi_fetch["vendor_id"]);

            $arrvendor[$i]["shipment"]=($shipment_date!=NULL) ? $shipment_date: "None";

            

            // then loop through contact

            $ssi_querys = "select contact_phone_1_text, contact_first_last_name from ssi_contact where vendor_id='$vid' order by sequence_number limit 1";

            $ssi_results = $connection->CreateCommand($ssi_querys)->query();

            $ssi_num_rows = $connection->CreateCommand($ssi_querys)->execute();

            

            if($ssi_num_rows > 0)

            {

                foreach($ssi_results as $ssi_fetchs)

                {

                    $cname = $ssi_fetchs["contact_first_last_name"];

                    $cnumber = $ssi_fetchs["contact_phone_1_text"];

                    $arrvendor[$i]["contacts"]=$cname;

                    $arrvendor[$i]["cnumber"]=$cnumber;

                }

            } else {

                $arrvendor[$i]["contacts"]="-";

                $arrvendor[$i]["cnumber"]="-";

            }

            $i++;

        }

        return $arrvendor;

    }// end function



panggil di controller :





        $listing=Vendor::model()->listVendor();

        

        // Create filter model and set properties

        $filtersForm=new FiltersForm;

        if (isset($_GET['FiltersForm']))

            $filtersForm->filters=$_GET['FiltersForm'];

 		

        // Get rawData and create dataProvider

        $filteredData=$filtersForm->filter($listing);

        $dataProvider=new CArrayDataProvider($filteredData, array(

        'sort'=>array(

            'attributes'=>array('id','name','contacts','shipment','items'),

            ),

        'pagination'=>array(

            'pageSize'=>10,

            ),

        ));

     			

        // Render

        $this->render('index', array(

            'filtersForm' => $filtersForm,

            'dataProvider' => $dataProvider,

        ));




di view :


/* @var $this VendorController */

/* @var $dataProvider CActiveDataProvider */


$this->menu=array(

	array('label'=>'Create Vendor', 'url'=>array('create')),

	array('label'=>'List Contact', 'url'=>array('/contact')),

	array('label'=>'Reset Filter', 'url'=>array('/vendor')),

);

?>

Vendor

<?php

$this->widget('bootstrap.widgets.TbGridView', array(

    'type'=>'striped bordered condensed',

    'dataProvider'=>$dataProvider,

    'template'=>"{items}\n{pager}",

    'filter'=>$filtersForm,

    'afterAjaxUpdate'=>"function(){jQuery('#FiltersForm_shipment').datepicker({'dateFormat': 'yy-mm-dd'})}",

    'columns'=>array(

        array('name'=>'seq', 'header'=>'No','filter'=>false),

        array('name'=>'name', 'type'=>'raw','value'=>'CHtml::link($data[name],"vendor/view/".$data[id])','header'=>'Name',

        'htmlOptions'=>array('class'=>'span2')

        ),

        array('name'=>'contacts', 'header'=>'Contact Name',

        'htmlOptions'=>array('class'=>'span2')

        ),

        array('name'=>'cnumber', 'header'=>'Contact Number','filter'=>false),

        array('name'=>'items', 'header'=>'Item Supplied',

        'filter'=>CHtml::listData(RawMaterial::model()->findAll(), 'raw_material_name', 'raw_material_name'),

        'htmlOptions'=>array('class'=>'span2')

        ),

        array('name'=>'shipment', 'header'=>'Last Shipment','type'=>'raw',

        'value'=>'($data[shipment]!=="None") ? date_format(new DateTime($data["shipment"]), "d F Y") : "None"',

        'filter'=>$this->widget('zii.widgets.jui.CJuiDatePicker', array(

            'name'=>'FiltersForm[shipment]',

            'attribute'=>'date',

            'options' => array(

                'dateFormat' => 'yy-mm-dd'

            )

        ), true),

        'htmlOptions'=>array('class'=>'span2')

        ),

        array(

            'class'=>'CDataColumn',

            'type'=>'raw',

            'value'=>'CHtml::link("Edit","vendor/update/".$data[id])',

            'header'=>'Edit Vendor',

            'filter'=>false,

 			),

        array(

            'class'=>'CDataColumn',

            'type'=>'raw',

            'value'=>'CHtml::link("Add","contact/create",array("target"=>"_blank"))',

            'header'=>'Add Contact',

            'filter'=>false,

 			),

        array(

            'class'=>'CDataColumn',

            'type'=>'raw',

            'value'=>'CHtml::link("Remove","vendor/delete/".$data[id],array("confirm"=>"Are you sure you want to remove this Vendor?","title"=>"Remove Vendor"))',

            'header'=>'Remove Vendor',

            'filter'=>false,

 			),

    ),

));

maaf agan2 apabila berantakan, ane baru belajar Yii :3


(Rezazuneva) #86

salam semua rekan… saya sedang memulia belajar YII Framework, sudah download ebook (terima kasih dengan sangat ya master)… kendalanya pass install yiic muncul error “php.exe - system error… the program can’t start because php_mbstring.dll missing from your computer”

NEED HELP????


(Dontworry) #87

salam kenal…!


(Ferrylukito2003) #88

PHP nya bermasalah kyanya,

coba download ulang aja PHP nya…


(Triosn) #89

salam kenal yaa om/sis ikutan gabung yii indonesia


(Depe0078) #90

Salam Kenal, saya baru mulai belajar Yii nh sob.

thx semua bwt yg dh sharing ilmu n tutorial2 yg bermanfaat.

saya mohon izin utk ambil informasi n tutorial yg diberikan. semoga kedepannya saya dpt kembangkan dan disharing di forum ini.

thx all.


(Hendrimamang) #91

Ijin gabung ya gan, baru buat id nya


(Viduka Animaniax) #92

mau nanya nih bro, saya ikutin tutorial yang ada d sini www . yiiframework . com / doc / guide / 1.1 /id/ quickstart.first-app

pada saat di bagian Mengakses halaman CRUD

http: // hostname / testdrive / index. php?r=user

ada error seperti ini

kalau di liat dari user\index.php (17)


<?php

$this->breadcrumbs=array(

	'Tusers',

);


$this->menu=array(

	array('label'=>'Create TUser', 'url'=>array('create')),

	array('label'=>'Manage TUser', 'url'=>array('admin')),

);

?>


<h1>Tusers</h1>


<?php $this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_view',

)); ?>



code di atas adalah code yang di generate dari gii… mohon pencerahannya… saya udah cari dan coba memahami tapi belum nemu solusinya…

terima kasih


(fredy musyadat) #93

mungkin bisa ke sini : yiiframework.com/doc/guide/1.1/id/quickstart.what-is-yii


(Belebek82) #94

:lol: [color="#2E8B57"]mentok sampe Juni 2014 yang 2015 nya pada kemana ya…??[/color] :unsure:


(Tsani Nashrullah) #95

maaf kang mau nanya kalo yii2 yang advanced sama basic apa bedanya yaa ?

mohon bimbingan nya saya pengguna baru


(Ullykharisma) #96

Yuk ramai kan lagi forum nya