本文整理汇总了PHP中PerchUtil::implode_for_sql_in方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::implode_for_sql_in方法的具体用法?PHP PerchUtil::implode_for_sql_in怎么用?PHP PerchUtil::implode_for_sql_in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::implode_for_sql_in方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_by
/**
* Get a collection of items where the given column matches the given value. e.g. get_by('catID', 2) would get all rows with catID=2.
* If $val is an array, does a SQL WHERE IN(array)
*
* @param string $col
* @param string $val
* @param string $order_by_col
* @return void
* @author Drew McLellan
*/
public function get_by($col, $val, $order_by_col = false, $Paging = false)
{
if (is_object($Paging)) {
$select = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT ';
} else {
$select = 'SELECT ';
}
if (is_array($val)) {
$sql = $select . ' * FROM ' . $this->table . ' WHERE ' . $col . ' IN (' . PerchUtil::implode_for_sql_in($val) . ') ' . $this->standard_restrictions();
} else {
$sql = $select . ' * FROM ' . $this->table . ' WHERE ' . $col . '=' . $this->db->pdb($val) . ' ' . $this->standard_restrictions();
}
if ($order_by_col) {
$sql .= ' ORDER BY ' . $order_by_col;
} else {
if ($this->default_sort_column) {
$sql .= ' ORDER BY ' . $this->default_sort_column . ' ' . $this->default_sort_direction;
}
}
if (is_object($Paging) && $Paging->enabled()) {
$limit = ' LIMIT ' . $Paging->lower_bound() . ', ' . $Paging->per_page();
$sql .= $limit;
}
$rows = $this->db->get_rows($sql);
if (is_object($Paging) && $Paging->enabled()) {
$sql = "SELECT FOUND_ROWS() AS count";
$total = $this->db->get_value($sql);
$Paging->set_total($total);
}
return $this->return_instances($rows);
}