BCS Yii Populate Array With Database Content

To fetch an array containing database values the Yii active record facility offers a nifty solution for achieving the desired overall effect.

$sql = 'SELECT * FROM slnk t order by t.lkn';
$query = Yii::app ()->db->createCommand ( $sql )->queryAll ();
foreach ( $query as $row ) {           
         // Include statements to generate here

There is no need for external connection modules or adding other files to the MVC stack, Yii handles it all for you. When you change databases none of this code requires updating.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply