Hi guys, i just found small bug (maybe) on "->params()" function.
Have you test this function to set params to inside of plain sql statement (not to comparasion statement e.g inside of 'WHERE') ?
Because when i try this code:
$sqlprodi = "
SELECT m1.k_jurusan_ppg, m1.keterangan
FROM gpodb.ajuan_ptk_ppg a1
LEFT JOIN gpodb.m_jurusan_ppg m1 ON a1.k_jurusan_ppg=m1.k_jurusan_ppg
WHERE a1.k_ajuan_ppg IN (2,3)
GROUP BY m1.k_jurusan_ppg, m1.keterangan
ORDER BY m1.keterangan
";
$this->src('gpo')
->query(
"
SELECT
CASE WHEN a.sekolah_id<>0 THEN m2.keterangan ELSE m21.keterangan END propinsi,
CASE WHEN a.sekolah_id<>0 THEN m5.keterangan ELSE m51.keterangan END kota,
m3.keterangan prodi,
COUNT(DISTINCT a.ptk_id) jml
FROM gpodb.ptk a
INNER JOIN gpodb.ajuan_ptk_ppg c ON a.ptk_id=c.ptk_id
LEFT JOIN gpodb.sekolah d ON a.sekolah_id=d.sekolah_id
LEFT JOIN (" .$sqlprodi. "LIMIT :prodilimit,10) m3 ON c.k_jurusan_ppg=m3.k_jurusan_ppg
LEFT JOIN gpodb.m_propinsi m2 ON d.k_propinsi=m2.k_propinsi
LEFT JOIN gpodb.m_kota m5 ON d.k_kota=m5.k_kota
LEFT JOIN gpodb.m_propinsi m21 ON a.k_propinsi=m21.k_propinsi
LEFT JOIN gpodb.m_kota m51 ON a.k_kota=m51.k_kota
WHERE c.k_ajuan_ppg IN (2,3) AND m3.keterangan IS NOT NULL
GROUP BY propinsi, kota, prodi
"
)->params(array(
":prodilimit"=>$this->params["prodilimit"],
))
->saveTo($prodi);
the result is the datastore has no data. But when i try this:
$this->src('gpo')
->query(
"
SELECT
CASE WHEN a.sekolah_id<>0 THEN m2.keterangan ELSE m21.keterangan END propinsi,
CASE WHEN a.sekolah_id<>0 THEN m5.keterangan ELSE m51.keterangan END kota,
m3.keterangan prodi,
COUNT(DISTINCT a.ptk_id) jml
FROM gpodb.ptk a
INNER JOIN gpodb.ajuan_ptk_ppg c ON a.ptk_id=c.ptk_id
LEFT JOIN gpodb.sekolah d ON a.sekolah_id=d.sekolah_id
LEFT JOIN (" .$sqlprodi. "LIMIT " .$this->params["prodilimit"]. ",10) m3 ON c.k_jurusan_ppg=m3.k_jurusan_ppg
LEFT JOIN gpodb.m_propinsi m2 ON d.k_propinsi=m2.k_propinsi
LEFT JOIN gpodb.m_kota m5 ON d.k_kota=m5.k_kota
LEFT JOIN gpodb.m_propinsi m21 ON a.k_propinsi=m21.k_propinsi
LEFT JOIN gpodb.m_kota m51 ON a.k_kota=m51.k_kota
WHERE c.k_ajuan_ppg IN (2,3) AND m3.keterangan IS NOT NULL
GROUP BY propinsi, kota, prodi
"
)
->saveTo($prodi);
it was successful