本文整理汇总了PHP中SearchResult::setFile方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchResult::setFile方法的具体用法?PHP SearchResult::setFile怎么用?PHP SearchResult::setFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult::setFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByAlamat
public function findByAlamat()
{
if ($this->before != null and $this->after == null) {
$sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%' AND tanggal>='" . $this->before . "'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "'";
} elseif ($this->before == null and $this->after != null) {
$sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%' AND tanggal<='" . $this->after . "'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat<='" . $this->after . "'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat<='" . $this->after . "'";
} elseif ($this->before != null and $this->after != null) {
$sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%' AND tanggal>='" . $this->before . "' AND tanggal<='" . $this->after . "'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "' AND a.tgl_surat<='" . $this->after . "'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "' AND a.tgl_surat<='" . $this->after . "'";
} else {
$sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%'";
$sql .= " UNION ";
$sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%'";
}
$sql .= " ORDER BY tgl DESC";
// var_dump($sql);
$data = $this->select($sql);
$result = array();
foreach ($data as $val) {
$cari = new SearchResult();
$cari->setId($val['id']);
$cari->setTanggal($val['tgl']);
$cari->setNomor($val['nomor']);
$cari->setPerihal($val['hal']);
$cari->setTipe($val['tipe']);
$cari->setFile($val['file']);
$result[] = $cari;
}
return $result;
}