Array is very helpful when you need to save some parameters temporary. In this post, i just want to write the sintax in vb 6.

Declare Array - same with other language declaration variables

Public arr2D() As String

Fill Array - I get data from database, then while looping data, it placed in array.
ReDim Preserve arr2D(DataCount - 1, 2) meaning : because array index from 0, then size array dataCount - 1 and 2 is array size that i want to save (it depends on requirement)

For i = 0 To DataCount - 1
    ReDim Preserve arr2D(DataCount - 1, 2)
    arr2D(i, 0) = i
    arr2D(i, 1) = Trim(rs!id)  
    arr2D(i, 2) = Trim(rs!name)  
    rs.MoveNext
Next

For example Datacount has 3 items, then :

0
 id0
 name0
1
 id1
 name1
2
 id2
 name2

- please correct me if i am wrong, but it works for me.

View Array - after fill array success, then you have to get data array to save or to preview in program.

If (Not arr2D()) = -1 Then   ----------- to check if array is empty
else 
       For i = 0 To UBound(arr2D)
              msgbox arr2D(i,0)
              msgbox arr2D(i,1)
              msgbox arr2D(i,2)
       Next i
End If

It usually looping in looping, but because  I know the size only 3 (2 size in array) , then I just loop 1 times.



When i upload file type 'rar' in CodeIgniter, there is a problem when upload. It showed warning : The filetype you are attempting to upload is not allowed.

The solution is quite simple, just edit in this file : services\application\config\mimes.php
add 1 line in $mimes array : 'rar'    =>    'application/octet-stream',

I think other file type will have that error too if it does not list at mimes.




I you have website and want to download or upload all files from your website, then you need something like Filezilla or WinSCP to download them. Actually what i write in here is in hosting help too.

This is how i did when i use Filezilla and hosting in Yahoo Small Business. Open the filezila, then click File -> Site Manager. It will show pop up window to fill the detail login to your website. Fill the
Host : ftp.yourwebsite.com
Protocol : FTP - File Transfer Protocol
Encryption : Require explisit FTP over TLS
Logon Type : Normal but you can choose other
User : user FTP that you have already created in your Yahoo Cpanel (i call it Cpanel) - make sure that u have already created it.
Password : ***
Then Connect. After that you can see right side and left side. Left side is our files or folders that we want to upload and the right side is files and folders in your website. If you want to upload or download, just make right click then you have options what will you do.

If you use  WinSCP, i don't know the explanation of what i fill to connect website, but here it is the detail to connect :
File Protocol : SFTP
Host Name : www.yourwensite.com
Port Number : 22
User name and password. Then click connect.





In my previous post, i have connection Yii with Oracle, then, when i move to my new office, they use sql server for database. It is almost the same as connection with oracle. Here we go,

  1. you must install sql client server, i use windows 7 and it need sql client server 2012. 
  2. download php_pdo_sqlsrv_54_nts.dll, php_pdo_sqlsrv_54_ts.dll, php_pdo_sqlsrv_53_nts.dll, php_pdo_sqlsrv_53_ts.dll. if u use php 5.4 then paste 54 or php 5.3 then paste 53 file. Then paste all the files into xampp\php\ext\, 
  3. then edit php.ini, like this : 
      extension=php_sqlsrv_54_ts.dll
      extension=php_pdo_sqlsrv_54_ts.dll


    4. restart apache..
    5. configure the yii files : protected\config\main.php like this :

             db'=>array(
            'connectionString' => 'sqlsrv:Server=LOCALHOST;Database=CPPermata',
            'username' => 'sa',
            'password' => 'sa1234',
            'charset' => 'GB2312',
        ),


then you can generate model by gii.. :D


I have a task to create company profile of company where i work. Then i decide using Yii framework to develop that. One of the fitur is news and it needs upload image to complete the news. I write in here just because i can open it again in the future. i realize that this way to upload is simpler than php non framework. here we go :

in view -> form, we have :

    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'news-form',
        'enableAjaxValidation' => false,

        'htmlOptions' => array('enctype' => 'multipart/form-data')
            ));
    ?>



        labelEx($model, 'newsImage'); ?>
       
        error($model, 'newsImage'); ?>
   

endWidget(); ?>

in models, we have :

class News extends CActiveRecord
{
    public $newsImage;


    //other function

    public function rules()
    {       
        return array(          
            array('newsId', 'numerical', 'integerOnly'=>true),
            array('newsTitle,  newsAuthor', 'length', 'max'=>200),
            array('newsImage', 'file', 'types'=>'jpg, gif, png'),
            array('user_in, user_up', 'length', 'max'=>8),
            array('newsDate, newsContent, date_in, date_up', 'safe'),
            array('newsId, newsTitle, newsDate, newsContent, newsImage, newsAuthor, user_in, date_in, user_up, date_up', 'safe', 'on'=>'search'),
        );
    }

    
    //other function
}

in controller we have save create example :

public function actionCreate() {
        $model = new News;
        if (isset($_POST['News'])) {
            $model->attributes = $_POST['News'];
            $model->newsImage = CUploadedFile::getInstance($model, 'newsImage');
            if ($model->save()) {
                $model->newsImage->saveAs(Yii::app()->basePath.'/../images/news/'.$model->newsImage);
                $this->redirect(array('view', 'id' => $model->newsId));
            }
        }

        $this->render('create', array(
            'model' => $model,
        ));
    }


I hope this help. I get reference from here :
http://www.yiiframework.com/wiki/2/how-to-upload-a-file-using-a-model/


Sometimes when u have many filters in your searching data, then u need query in string format. It's avoid many 'if else' of field that u use to filter. I have a senior programmer who tell me how to write the sp. Here we go the example :

BEGINSET NOCOUNT ON;
declare @str NVarchar(4000) , @where varchar(2000), @UserId char(8)
select @UserId = 'U0000000', @where = '(m.DocumentKeywords like ''%og%'' or m.DocumentKeywords like ''%og%'') AND convert(datetime,m.DocumentCreatedDate,106) between ''01 Mar 2013'' and DATEADD(DAY, +1,''31 Mar 2013'')'
set @str=N'SELECT distinct m.DocumentId, m.DocumentName
FROM dbo.DocumentsAccess a inner join dbo.Documents m on a.DocumentId=m.DocumentId and m.stsrc <> ''D''
inner join Users u on m.DocumentCreatedById = u.UserId
left join Users um on m.DocumentModifiedById = um.UserId and u.stsrc <> ''D''
WHERE (a.Stsrc <> ''D'' and a.canAccess=''1'' and a.UserId = '''
+ @UserId + ''') and '

set @str=@str+'('+@where +')'
+ 'ORDER BY m.DocumentName '

exec sp_executesql @str
print @str

END Then the result will be :

SELECT distinct m.DocumentId, m.DocumentName
FROM dbo.DocumentsAccess a inner join dbo.Documents m on a.DocumentId=m.DocumentId and m.stsrc <> 'D'
inner join Users u on m.DocumentCreatedById = u.UserId
left join Users um on m.DocumentModifiedById = um.UserId and u.stsrc <> 'D'
WHERE (a.Stsrc <> 'D' and a.canAccess='1' and a.UserId = 'U0000000') and ((m.DocumentKeywords like '%og%' or m.DocumentKeywords like '%og%') AND convert(datetime,m.DocumentCreatedDate,106) between '01 Mar 2013' and DATEADD(DAY, +1,'31 Mar 2013'))ORDER BY m.DocumentName
 


Install Yii sebenarnya mudah, aku menuliskannya disini karena takut lupa. heheheh... :)
spesifikasi yang aku pakai : xampp 1.7.7

1. download source yii...
2. extract file source, bisa ditaro dimana saja, tp ak taro di htdocs jg.
3. buka cmd, dan mengetikkan perintah seperti dalam gambar.
dan selesai instalasi yii nya. hehehe..