I’ve been fighting this all day. I give up.
I’m trying to use SQLDataProvider with a cListView but it’s not working.
I’m getting this error:
CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute… The SQL statement executed was: SELECT group_name
, id
FROM groups
WHERE userId
= 3
This is my test controller:
<?php
class TestController extends Controller
{
public function actionIndex()
{
$FollowupStudents=$this->loadFollowupDP();
$this->render('index',array(
'FollowupStudents'=>$FollowupStudents,
));
}
public function loadFollowupDP()
{
$sql="SELECT id, note FROM careguide_followup;";
$ic = 6;
$dp = new CSqlDataProvider($sql, array('keyField' => 'Id', 'totalItemCount'=>$ic));
return $dp;
}
}
This is my view:
<?php
/* @var $this TestController */
$this->breadcrumbs=array(
'Test',
);
?>
<h1><?php echo $this->id . '/' . $this->action->id; ?></h1>
<div>
<table id="followup" class="table" style="background-color: #FFFFFF;">
<thead>
<tr>
<th>User</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$FollowupStudents,
'itemView'=>'_FollowupRow',
)); ?>
</tbody>
</table>
</div>
This is my row template:
<tr>
<td><?php echo $data->id; ?></td>
<td><?php echo $data->Note; ?></td>
</tr>
The reason I want to use SQL directly is I have three related tables and I need to use a UNION with three other related tables.
And I’m thinking that if can get this to work it will be very useful later on.
But if it won’t work in this simple test…
Any help will be appreciated.
Gary