[VB6 / VB.NET ] Create OLEDB String Connection

Deskripsi
 Many newbie programmer maybe ask, how to create string connection to database (sqlserver , oracle etc) with OLEDB ? this is actually easy :D , oke let's to the tutorial !!

Howto
1. make sure that you have installed the OLEDB that accordance with the type of your database
2. Create file text in desktop , for example conn.txt
3. Rename the extention to .UDL (Microsoft Data Link)
4. Double Click to conn.udl , and go to TAB PROVIDER, your installed provider will be list in there.
5. Go to TAB CONNECTION and insert your host, username , password and don't forget allow saving password and test connection
6. if test connection success, then Save / OK
7. Right click on the conn.udl, open with NOTEPAD or another text application.
8. VOILA !! you get the connection string automatically !! (string on the red line)


[E-Bussiness Suite] Limit Attachment File Size


Deskripsi
     Untuk membatasi attachment yang diupload secara global, baik melalui attachment purchasing requisition maupun pada purchasing order pada ERP - EBS.

Howto
1. Goto Profiler > System > Find > 'Upload File Size Limit'
2. Add Value in KB (KiloByte)
3. Save

Jika Upload misalkan dibatasi max 2MB dan kemudian diupload files dengan size diatas 2MB maka akan seharusnya akan muncul 'Exception' / gagal. jika tidak ada exception dan files berhasil tembus kemungkinan besar terdapat bugs, untuk pertolongan lebih lanjut contact metalink support atau support vendor oracle anda.

[E-Bussiness Suite] Query list all allocation storage database


Deskripsi
      DBA_SEGMENTS describes the storage allocated for all segments in the database.

How to
list all segment :
select *
from dba_segments

list segment table only :
select *
from dba_segments
where segment_type='TABLE'

list segment table for attachment : 
select *
from dba_segments
where segment_type='TABLE'
and segment_name = 'FND_LOBS'

[E-Bussiness Suite] Query get all attachment file size in oracle db


Deskripsi
    FND_LOBS table is one of the largest objects in an E-Business Suite instance. FND_LOBS table contains all the attachments which were attached by users in all the modules of EBS. the attachment go into fnd_lobs table as large objects. Not stored in Unix box or other.

Howto

get data file size every attachment :
select file_id
        ,file_name
        ,upload_date
        ,dbms_lob.getlength(file_data) size_In_byte
        ,file_content_type
        ,file_format
        ,language
        ,oracle_charset
from fnd_lobs;

get total size all attachment
select count(dbms_lob.getlength(file_data))
from fnd_lobs;

*tested, works

[E-Bussiness Suite] Query PR - PO - RR - INV_NUM - VCHR_PAYMENT


Deskripsi
    Query dibawah ini dapat melisting data mulai dari PR sampai Payment, MANTAP !!!! :D, untuk field"nya tinggal menyesuaikan mana yang ingin ditampilkan.

Howto
1. Activate show hidden view (we use invoice and payments view), you can see the instruction HERE
2. Running this query
----------------------------------------------------------------------------
select distinct        PRHA.segment1 as PR
                            , PHA.segment1 as PO
              ,RVHV.RECEIPT_NUM as RECEIPT_NUMBER
                    ,AI.INVOICE_NUM as INVOICE
,AC.DOC_SEQUENCE_VALUE as VOUCHER_PAYMENT
         
from po_requisition_headers_all PRHA
       ,po_requisition_lines_all PRLA
       ,po_line_locations_all PLLA
       ,po_headers_all PHA
       ,po_lines_all PLA
       ,po_distributions PD
       ,RCV_SHIPMENT_LINES RSL
       ,RCV_VRC_HDS_V RVHV
       ,ap_invoice_distributions AID
       ,AP_INVOICES AI
       ,AP_INVOICE_PAYMENTS_V AIP
       ,AP_CHECKS AC
     
where PRHA.segment1= :PR_NUMBER
and prha.requisition_header_id = PRLA.requisition_header_id(+)
and PRLA.line_location_id = PLLA.line_location_id(+)
and PHA.po_header_id(+) = PLA.po_header_id
and PLA.po_line_id(+) = plla.po_line_id
AND PHA.po_header_id = RSL.po_header_id (+)
AND RSL.shipment_header_id = RVHV.shipment_header_id(+)
AND PD.po_header_id(+) = PHA.po_header_id
AND AID.po_distribution_id(+) = PD.po_distribution_id
AND AI.INVOICE_ID(+) = AID.INVOICE_ID
AND AI.INVOICE_ID = AIP.INVOICE_ID(+)
AND AIP.CHECK_ID = AC.CHECK_ID(+);

[PHP] Array


Deskripsi
      Cara membuat array, menambahkan/push array ke array, serta mengubah value dari array php.

Howto
//create array
$myarray = array("permission" => array(
                                               "Main" => "true"
                                    ),
                  "Grants" => array(
                                             "Local" => "true"
       )
            );

//Accessing Array
echo $myarray["permission"] // output = array, because another array still exist
echo $myarray["permission"]["Main"] // output = true , because there's only leaf

//Count Array
echo count($myarray); // output 2 (permission and grant, another array not include)

//Count Array Recursive
echo count($myarray,COUNT_RECURSIVE); // output 4 (permission,grant,main,local)

//Add content
array_push($myarray["Grants"],array('suicide'=>'Yes'));
result : array("permission" => array(
                                               "Main" => "true"
                                    ),
                  "Grants" => array(
                                             "Local" => "true"
       ),
                                                      array(
                                             "suicide" => "true"
       ),
     );

//Compac Function
$name = "mahendra";
$position = "IT";
$detail=array("name","position");
$result=compact($detail);

print_r($result);

here's the result:
Array ( [name] => mahendra [position] => IT )

if i comment variable $position, the result:
Array ( [name] => mahendra )

*because the value not linking to same name of variable.

[PHP] Connect Oracle Database


Deskripsi
     Tutorial mengenai koneksi php ke oracle database menggunakan OCI.

Howto
1. You must have OCI Extention, if you don't have you can Download Here
2. Extract Extention in PHP5.x.x/Ext/[Extract Here]
3. Find Php.ini and add the extention, if you don't know how to add extention on php , find on google first.
4. Download and install Oracle Instant Client
5. Download and install Oracle Client Here
6. Create file TNSname.ora at Admin Folder in your Oracle Client, and add this line
// Based on you setup, it's only sample
DB_NAME =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS =
        (PROTOCOL = TCP)
        (HOST = XX.XX.XX.XX)
        (PORT = 1526)
      )
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ServiceOrSID)
    )
  )

7. if all setup complete, now you can connect to oracle database from php with this code
<?php
$host = 'XX.YY.ZZ.GG';
$port = 1526;
$database_name = 'test';
$username = 'user';
$password = 'test';
$SIDorServiceName = 'myservice';

$TNSEditor = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $host)(PORT = $port))
(CONNECT_DATA = (SID = $SIDorServiceName)))";

$statusOra = oci_connect("$username", "$password", $TNSEditor);

if($statusOra)
{
echo "connect sukses"."<br>";
$stid = oci_parse($statusOra, 'SELECT * FROM table where rownum <= 1');
oci_execute($stid);

while ($row = oci_fetch_array($stid,OCI_BOTH))
{
//echo $row["TASK_NAME"]."<br>";
  //echoing your field here
}
}
else
{
echo "connect failed";
}
oci_close($statusOra);
?>

[PL/SQL] Basic PL/SQL Oracle Report 6i

Deskripsi
     Basic Syntax dari PL/SQL cocok untuk programmer yang ingin membuat report menggunakan Oracle Report 6i.

Howto
// Basic Syntax
Declare
    -- your variable
begin
    -- your statement
end;


// Basic Variable
       myvar varchar (20);


// basic variable constant 
      myvar varchar (20) := 10;


// Basic Function
function ZZZ return Char is
    -- your variable without declare
begin
   -- your statement
end;


// Conditional Statement
 IF kondisi1 THEN 
     --xxx
ELSE 
    --yyy
   IF kondisi2 THEN 
        --fff
    END IF; 
    ELSIF kondisi3 THEN 
       --hhh
    END IF;


// Loop Statement
For cnt IN 1..10
     -- statement
END LOOP;

While condition1
     -- statement
END LOOP;

[Cakephp] Query Join

Deskripsi
      Berikut adalah cara join manual selain menggunakan relationship pada model , tapi itu tergantung bagaimana style anda dalam mengcoding, selamat belajar

Howto
1. Saya punya database (SQL Server 2005) dengan Spec berikut (contoh)  :
    table :  1. tr_client // transaction table
                         field : - id [PK]
                                  - id_client // this data refers to table ms_client
                                  - transaction

               2. ms_client // base table as master client
                                  - id_client [PK]
                                  - name
                                  - address


Model for tr_client without relationship (standart model) :
   <?php
   class tr_client extends AppModel
   {
    var $name = 'tr_client';
    var $useDBConfig = 'default';
    var $useTable = 'tr_client';
    var $primaryKey = array('id');
    }
   ?>


 2. Basic Statement Join Code :
         'joins' => array(
                                   array('table' => 'table_join',
                                             'alias' => 'alias',
                                             'type' => 'left/right',
                                   'foreignKey' => false/true,
                                      'conditions'=> array('condition here'))),

3. How to Query
   $data = $this->tr_client ->find('all', array(
                                                                   'field' => array(
                                                                                            'tr_client.transaction,
                                                                                            'master_client.name'),
                                                                   'joins' => array(
                                                                                                    array('table' => 'ms_client ',
                                                                                                         'alias' => 'master_client',
                                                                                                              'type' => 'left',
                                                                                                    'foreignKey' => true,
                                                                                                       'conditions'=> array('
                                                                             tr_client.id_client = master_client.id_client
                                                                                                                             '))),
                                                                          'limit' => 10,
                                                       'conditions' => array('
tr_client.transaction' => 'approve'));

look at the green and yellow mark, you can learn it.

hope's this help :D

[Cakephp] Join Using Relationship

Deskripsi
     Mempelajari bagaimana cara menghubungkan relationship antara 2 model yang saling terkait, untuk tutorial kali ini saya akan menghubungkan kedua model melalui perantara foreign key, salah satunya bertindak sebagai base table karena dalam realitanya cara ini yang paling sering digunakan. untuk jenis relation lainnya bisa dipelajari sendiri.

Howto
1. Saya punya database (SQL Server 2005) dengan Spec berikut (contoh)  :
    table :  1. tr_client // transaction table
                         field : - id [PK]
                                  - id_client // this data refers to table ms_client
                                  - transaction

               2. ms_client // base table as master client
                                  - id_client [PK]
                                  - name
                                  - address
 
   Model for tr_client :
   <?php
   class tr_client extends AppModel
   {
    var $name = 'tr_client';
    var $useDBConfig = 'default';
    var $useTable = 'tr_client';
    var $primaryKey = array('id');
    }
   ?>

   Model for ms_client :
   <?php
   class ms_client extends AppModel
   {
    var $name = sm_client';
    var $useDBConfig = 'default';
    var $useTable = 'sm_client';
    var $primaryKey = array('id_client');
   ?>

   Now we create relation between 2 table, we add code at tr_client model,  why ? because that model which need the data, not ms_client model.

what's the code to create relationship ? here's :
    var $belongsTo = array(
                           'ms_client' => array('className' => 'ms_client',
                                                         'foreignKey' => 'id_client'
                           ));
* look at the green mark, you can learn it.


now add the code to tr_client :
 
   <?php
   class tr_client extends AppModel
   {
    var $name = tr_client';
    var $useDBConfig = 'default';
    var $useTable = 'tr_client';
    var $primaryKey = array('id');
 
    var $belongsTo = array(
                           'ms_client' => array('className' => 'ms_client',
                                                         'foreignKey' => 'id_client'
                            ));
    }
   ?>

ok , all done now when you query using statement something like this :
        
$data = $this->tr_client->find('all', array( 'field' => array( 'ms_client.name',
                                                                                       'tr_client.transaction',
                                                                          'limit' => 10,
                                                                          'conditions' => array('
tr_client.id' => '1'),
                                                                          'order'=>array('
ms_client.name=> 'ASC'));

* look at the green mark, we using tr_client model but we can grab field from another model, That's relationship !! easy right ?


what if we have multiple relation ?? how we do that ? look's this code and you'll be understand : 

    var $belongsTo = array(
                           'ZZZ' => array('className' => 'ZZZ',
                                                  'foreignKey' => 'AAA'
                                                 ),
        
                           'XXX' => array('className' => 'XXX',
                                                  'foreignKey' => 'BBB'

                                                 ),
   };


hope's this help :)

[YII] Join + CGridView + Pagination


Deskripsi
      if we have 2 table or more you can joined easily, but in Yii we must create relationship before using it.      
Howto
1. Setup Relation
    i have 2 Table with spec :
       - table 1 name : Yiitest
          field :   1. id [PK]
                     2. name
                     3. Description
   
          -----Join table using field name ------

        - table 2 name : Yiitest2
          field :   1. name [PK]
                     2. position

* Case : i need join table Yiitest to Yiitest2, and Yiitest.name based on Yiitest2.name[PK]
    How we do that ?? just create relationship
 
    Go to your model Yiitest and add this code line
    public function relations()
    {
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'Yiitest2'=> array(self::BELONGS_TO,'Yiitest2','name'),
);
    }
 
    * Relation have been create, now we can query using CActiveDataProvider


2. Query Join with CActiveDataProvider
    Controller : 
    $dataProvider = new CActiveDataProvider('Yiitest',array(
                                                    'criteria'=>array('join'=>'right join yiitest2 x on x.name = 
                                                                                         t.name',
                                                                             'order' => 'id'),
                                                    'pagination'=>array('pageSize'=>2),));
   // send object to view
    $this->render('your_view', array('dataProvider' => $dataProvider));
   
    *look at red mark, because we use join that model using alias 't' (by default Yii).


3. Display Using CGridView with Join Field and Pagination 
   View : 
   <?php
   $this->widget('zii.widgets.grid.CGridView', array(
                                  'dataProvider'=>$dataProvider,
                                  'columns'=>array('name','description','Yiitest2.position'),
                                  'pager'=>array(
                                                          'class'=>'CLinkPager',
                                                          'header'=>'',
                                                          'prevPageLabel'=>'<',
                                                          'nextPageLabel'=>'>',
                                                          'firstPageLabel'=>'First',
                                                          'lastPageLabel'=>'Last',
                                                          ),
                                 'enablePagination' => true,));
   ?>
 
   * look at cyan mark , Why Yiitest2 ? not Yiitest ? because field position in model Yiitest2 haha ,
      simple right ?
   * if you don't want pagination just change the value to false

[YII] Pagination


Deskripsi
     This pagination Using CActiveDataProvider , zii.widgets.grid.CGridView and ClinkPager.

Howto
Controller : 
// create ActiveDataRecord Object, with option pagination
$dataProvider = new CActiveDataProvider('MODEL',array('criteria'=>array('order' => 'id'),  
                                                                                   'pagination'=>array('pageSize'=>2)
                                                                   ));
// Passing that object to view, we don't need using method getData()
$this->render('your_view', array('dataProvider' => $dataProvider,));

View :
//use widget CGridView and class CLinkPager
$this->widget('zii.widgets.grid.CGridView', array(
                                                                  'dataProvider'=>$dataProvider,
                                                                 'pager'=>array(
                                                                     'class'=>'CLinkPager',
                                                                     'header'=>'',
                                                                      'prevPageLabel'=>'<',
                                                                     'nextPageLabel'=>'>',
                                                                      'firstPageLabel'=>'First',
                                                                     'lastPageLabel'=>'Last',),
                                                                  'enablePagination' => true,
));

*look at the mark , that's the basic pagination with widget CGridView and CLinkPager.

[Cakephp] Add CSS and JS File

Deskripsi
           Berikut adalah cara mengembed file external dari css dan js.


Howto
     1. You must have .css and js file.
    
     2. - your css file path : webroot\CakeApp\app\webroot\css\[create or copy here]
         - your script file path : webroot\CakeApp\app\webroot\js\[create or copy here]
    
     3. Add this script to your view
        <?php echo $this->Html->css('style'); // no need .css ?>

        <?php echo $this->Html->script('jquery-1.8.2'); // no need .js?>

     4. now your script and css will connect to view


[YII] Add CSS and JS File


Deskripsi
     Berikut adalah cara mengembed file external dari css dan js.

Howto
     1. You must have .css and js file.
   
     2. - your css file path : webroot/Yiiapp/css/[create or copy here]
         - your script file path : webroot/Yiiapp/js/[create or copy here] , if doesn't exist create
            first
   
     3. Add this script to your view
        <?php
        Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/css/style.css');
        Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/test.js');
        ?>
        * no need to echo in view

     4. now your script and css will connect to view

[YII] Pretty Url


Deskripsi
     Secara pengaksesan standart YII punya format url yang mengerikan / horrible, so jadi bagaimana agar kita membuat URL yang cukup cantik dan simple pada YII. simple just follow my step

Howto
1. First access URL in YII like this :
    localhost/myYii/index.php?r=controller/action

2. i want to change like this :
    localhost/myYii/index.php/controller/action

3. Open config.php at path : webroot/YourYiiApp/protected/config/config.php
4. Find and Uncomment this string code :

              // uncomment the following to enable URLs in path-format
             'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
 ),

5. Now your url like this
    localhost/myYii/index.php/controller/action

6. it's still bad i want to remove index.php, haha ok to remove index.php we need .htaccess

7. create .htaccess at this path : webroot/myYii/[your htaccess here]

8. copy paste code below to your htaccess
 
    Options +FollowSymLinks
    IndexIgnore */*
    <IfModule mod_rewrite.c>
    RewriteEngine on

    # if a directory or a file exists, use it directly

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # otherwise forward it to index.php

   RewriteRule . index.php
   </IfModule>
 
9. now your URL like this :
     localhost/myYii/controller/action

10. How about the parameter ? , i want to passing the value from url to my action in controller , simply follow this :
      localhost/myYii/controller/action?myvar1=1&myvar2=2

11 In method  you can do this
   
     in your action on controller

     public function actionXXZZ($myvar1,$myvar2)
     {
           echo $myvar1;
     }

*beware !! the name of variable in URL must same in action parameter it's very different with Cakephp.

ok all done , hope's this help

[Cakephp] Basic Form

Deskripsi
       Form digunakan sebagai interaksi antara user dan system, interaksi berupa inputan yang digunakan untuk berbagai macam keperluan, seperti register , login , penyimpanan data , etc.

Howto
<table border="0" width="500px;" style="margin-left:10px;" cellspacing="2px;">

            <?php echo $this->Form->create('MODEL', array(
                                   'id'=>'ID_FORM',
                                   'url'=>array(
                                                     'controller'=>'controller',
                                                      'action'=>'action')))
            ?>

            <td>USERNAME</td>
            <td style="text-align:left;padding-left:4px;">
            <?php echo $this->Form->input('USERNAME',array('label'=>false,'style'=>'width:370px'))
             ?>
            </td>

        <?php echo $this->Form->submit('submit_button')?>
        <?php echo $this->Form->end()?>

</table>

Explanation :
* normally you don't need the table, this only sample my code when using form in intranet application.

to create form :  $this->Form->create(MODEL,array(OPTION)); // must have at least 1
to create input : $this->Form->input(MODEL,array(OPTION));
to create submit button : $this->Form->submit('submit_button'); // must have at least 1
to create end tag : $this->Form->end() // must have at least 1

for OPTION , you can read online manual.

after you submit form , you form data exist in variable data in controller, how to call :

$this->data;

variable data is an array variable so if you want to see the value :

print_r($this->data);

if you want to change the value :

$this->request->data['xxx']['zzz'] = 'this is the new one'

if you want to save the database :

$this->model->save($this->data);
  

[YII] Basic Form


Deskripsi
     Form digunakan sebagai interaksi antara user dan system, interaksi berupa inputan yang digunakan untuk berbagai macam keperluan, seperti register , login , penyimpanan data , etc.

Howto

in CONTROLLER on action Formulir :

     public function actionFormulir()
{
1 $model = new Yiitest;
2
3 if(isset($_POST['Yiitest']))
4 {
5 $model->name = $_POST['Yiitest']['name'];
6 $model->description = $_POST['Yiitest']['description'];
7 if ($model->save())
8 {
9 echo 'Berhasil disimpan';
10 }
11 else
12 {
13 echo 'Save Failure'.'<br>';
14 $error = $DbAr->getErrors();
15 echo $error['name']['0'];
16 }
17 }
18 else
19 {
20 $this->render('formulir',array('model'=>$model));
21 }
22 }

* why line 3 not true ? because the form is not recognize and the variable sent method post doesn't exist so the first execute is line 20

* look at number line 20 , we passing object model from CONTROLLER to VIEW, now we look view


in VIEW Formulir, you can learn this  :
<div class="form">
<?php $form=$this->beginWidget('CActiveForm'); ?>

    <?php echo $form->errorSummary($model); ?>

<div class="row">
        <?php echo $form->label($model,'name'); ?>
        <?php echo $form->textField($model,'name') ?>
    </div>

<div class="row">
        <?php echo $form->label($model,'Deskripsi'); ?>
        <?php echo $form->textField($model,'description') ?>
    </div>

    <div class="row submit">
        <?php echo CHtml::submitButton('Simpan'); ?>
    </div>

<?php $this->endWidget(); ?>
</div><!-- form -->

* name and description is field on database
* method default is post and the data is send to current controller and current action, that's why after you click submit button the variable will be created and line 3 in controller will be executed

[YII] Basic CRUD


Description

        Memahami basic dari Create , Read , Update, and Delete.

Skill : *  Basic SQL - DML (Data Manipulation).

           * Basic Form , Controller , Model YII

How To :
        Untuk membuat agar web yang dibuat menggunakan framework YII bisa input data , edit data , atau  delete data sebetulnya tidak harus memahami penulisan syntax SQL karena memang sudah disediakan. tetapi pemahaman untuk SQL wajib didalami jika suatu saat ada kondisi yang tidak memungkinkan untuk menggunakan library dari framework YII ini.

       Untuk bisa melakukan CRUD pada YII , bisa dihadapkan 2 pilihan langsung yaitu mengakses classnya si model secara langsung (namescope) atau merubah dulu menjadi object, terserah sih itu pilihan anda tapi kebanyakan  rata menggunakan namescope mengakses classnya si model secara langsung tapi terkadang ada case" tertentu untuk menggunakan object. tapi di tutorial ini saya lebih menggunakan object karena sudah terbiasa dengan Framework Cakephp haha, ok to the point !


Our Setup :

  - Database Name : yii
  - Table Name : yiitest
     - Field 1 : id
     - Field 2 : name
     - Field 3 : description
  - Yii Model Name : Yiitest
  - Yii Controller Name : contoh

BASIC INPUT 

example:

class contohController extends Controller
{
     ...........another code ...........
     ...........another code ...........


       public function actionInsertion()
       {

       $AbstractDB = new Yiitest

       $AbstractDB ->name='Griffindor';
       if ($AbstractDB ->save())
       {
           echo 'Save Sukses';
       }
       else
       {
echo 'Save Failure'.'<br>';
$error = $AbstractDB ->getErrors();
        print_r($error);
       }
       $this->render('Insertion');
       }
}



BASIC EDIT

class ContohController extends Controller
{
     ...........another code ...........
     ...........another code ...........


       public function actionUpdating()
       {
               $AbstractDB = new Yiitest;
                // $AbstractDB ->updateByPk(PK_VALUE, array('FIELD'=>'NEW_VALUE'));
$AbstractDB ->updateByPk(1, array('description'=>'sukses bro'));
unset($DbAr);
       }
}




BASIC DELETE

class ContohController extends Controller
{
     ...........another code ...........
     ...........another code ...........


       public function actionDeleting()
       {
$AbstractDB =Yiitest::model();
$store= $AbstractDB ->find("name=:values",array(':values'=>'ravenclaw'));
$AbstractDB ->deleteByPk($store['id']);
               // hey look at ':values' the values refers to  ':values'=>'ravenclaw'
       }
}



BASIC READ
example:
class ContohController extends AppController
{
   ...........another code ...........
   ...........another code ...........


 public function actionReading()

 {
     // to get data from database we use CActiveDataProvider Class
     $dataProvider = new CActiveDataProvider('Yiitest');
     $resultSet = $dataProvider->getData();
     foreach ($resultSet as $datax)
     {
          echo $datax['id'].' '.$datax['name'].' '.$datax['description'].'<br>';
     }
  }
}

if you want datalist for value object Html like a list box you use this :

class ContohController extends AppController
{
   ...........another code ...........
   ...........another code ...........


 public function actionReading()

 {
     // to get data from database we use CActiveDataProvider Class
     $data = Yiitest::model()->findAll();
     $datacache = CHtml::listData($data,'id','name');
     print_r ($datacache);
     // the data looks like this 
     //Array ( [1] => mahendra )
     // [1] is value in field id
     // [mahendra] is value in field name 
  }
}