To fetch an array containing database values the Yii active record facility offers a nifty solution for achieving the desired overall effect.
[codesyntax lang=”php”]
$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 <?php } ?>
[/codesyntax]
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.