Yii Framework Forum: (Solved) Bermasalah Saat Render Tabel Menggunakan Pure Sql - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

(Solved) Bermasalah Saat Render Tabel Menggunakan Pure Sql SQL dan Yii master mohon bantuannya Rate Topic: -----

#1 User is offline   krisna 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 21-July 13

Posted 23 August 2013 - 12:14 PM

Assalamualaikum
gan saya kan di controller pake sql kayak gini

Quote

public function actionTabel5122S1(){
$dataProvider=array();
//$sql = 'SELECT * FROM mata_kuliah';
$sql = ('Select * FROM mata_kuliah where kode LIKE "___1%" OR kode LIKE "___2%"
OR kode LIKE "___3%" OR kode LIKE "___4%"
GROUP BY id order by semester ASC');
$sum_bobot_sks = Yii::app()->db->createCommand('Select SUM(bobot_sks) FROM mata_kuliah where kode LIKE "___1%" OR kode LIKE "___2%"
OR kode LIKE "___3%" OR kode LIKE "___4%"
')->queryScalar();
$sum_sks_inti = Yii::app()->db->createCommand('Select SUM(SKS_inti) FROM mata_kuliah where kode LIKE "___1%" OR kode LIKE "___2%"
OR kode LIKE "___3%" OR kode LIKE "___4%"
')->queryScalar();
$dataProvider=new CSqlDataProvider(array($sql, $sum_bobot_sks, $sum_sks_inti,array('keyField'=>'id')));
return $dataProvider;
$this->render('../tabelS1/tabel5122', array('dataProvider'=>$dataProvider));
}


terus di render di view/tabelS1/tabel5122.php yang isinya kayak gini

Quote

<?php
foreach($dataProvider->getData() as $dat=>$data) { ?>
<tr>
<td><?php echo $data['semester']; ?></td>
<td><?php echo $data['kode']; ?></td>
<td><?php echo $data['nama']; ?></td>
<td><?php echo $data['sistem_kredit_semester']; ?></td>
<td></td>
<?php } ?>


pas ngeklik ke menu tabel5122 kok gak muncul apa-apa ya (di browser kayak blank page gitu). Mohon penjelasannya. Makasih ya para master. Ilmu yang dishare sangat bermanfaat
0

#2 User is offline   krisna 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 21-July 13

Posted 24 August 2013 - 03:14 AM

SOLVED!

Quote

di model buat kayak gini
$criteria = new CDbCriteria;
$criteria->condition = "kode LIKE concat (:kode, '___1%') OR kode LIKE concat (:kode, '___2%')
OR kode LIKE concat (:kode, '___3%')
OR kode LIKE concat (:kode, '___4%')";
$criteria->params = array(':kode'=> MataKuliah::model()->getAttribute('kode'). '%');
return $this->model()->findAll($criteria);


terus di Contoller buat kayak gini

Quote

public function actionTabel5122S1(){

$dataProvider = MataKuliah::model()->tabel5122S1();
$this->render('../tabelS1/tabel5122', array('dataProvider'=>$dataProvider));
}


render tabelnya kayak gini

Quote

<?php
foreach($dataProvider as $data) { ?>
<tr>
<td><?php echo $data['semester']; ?></td>
<td><?php echo $data['kode']; ?></td>
<td><?php echo $data['nama']; ?></td>
<td><?php echo $data['sistem_kredit_semester']; ?></td>
<?php } ?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users