Acceso a Datos con SQL¶
En el controlador
use yii\db\Query;
use yii\helpers\Html;
public function actionPdf($id) { $mpdf=new mPDF(); $mpdf->AddPage('utf-8','Letter','V','',15,15,35,25,9,9,'P'); if (isset($_GET['id'])) { $query = new Query; $query->select(['t_personas.nombre as persona','fecmov','concepto','debe', 'haber'])->from('t_ctacte')->join('INNER JOIN', 't_cuentas_personas', 't_cuentas_personas.id = t_ctacte.idcuentapersona')->join('INNER JOIN', 't_personas', 't_cuentas_personas.idpersona = t_personas.id')->where('idcuentapersona='.$_GET['id']); $command = $query->createCommand(); $data = $command->queryAll(); $html = '<table>'; foreach ($data as $row) { $html .= '<tr>'; $html .= '<td>' . $row['persona'] . '</td>'; $html .= '<td>' . $row['fecmov'] . '</td>'; $html .= '<td>' . $row['concepto'] . '</td>'; $html .= '<td>' . $row['debe'] . '</td>'; $html .= '<td>' . $row['haber'] . '</td>'; $saldo=$row['haber']-$row['debe']; $diferencia=$diferencia-$saldo; $html .= '<td>' . $diferencia . '</td>'; } $html .= '</table>'; $mpdf->WriteHTML($html); //return Html::encode($html); } $mpdf->Output(); exit; }