本文整理汇总了PHP中Tool::setHtmlString方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::setHtmlString方法的具体用法?PHP Tool::setHtmlString怎么用?PHP Tool::setHtmlString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tool
的用法示例。
在下文中一共展示了Tool::setHtmlString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select
protected function select(array $selectFields, array $param, $tables)
{
$limit = $order = $where = $fromTables = $like = '';
$fields = implode(',', $selectFields);
//处理筛选条件
if (!Validate::isNullArray($param)) {
$limit = isset($param['limit']) ? ' LIMIT ' . $param['limit'] : '';
$order = isset($param['order']) ? ' ORDER BY ' . $param['order'] : '';
if (isset($param['where'])) {
$isAnd = '';
foreach ($param['where'] as $value) {
$isAnd .= $value . ' AND ';
}
$where = ' WHERE ' . substr($isAnd, 0, -4);
}
if (isset($param['like'])) {
foreach ($param['like'] as $key => $value) {
$like = " WHERE {$key} LIKE '%{$value}%'";
}
}
}
//处理多表联查
foreach ($tables as $value) {
$fromTables .= $value . ' ,';
}
$fromTables = substr($fromTables, 0, -1);
$sql = "SELECT {$fields} FROM {$fromTables} {$where} {$like} {$order} {$limit} ";
$stmt = $this->execute($sql);
$result = array();
while (!!($obj = $stmt->fetchObject())) {
$result[] = $obj;
}
return Tool::setHtmlString($result);
}
示例2: select
protected function select($_tables, array $_field, array $_param = array())
{
$_limit = '';
$_order = '';
$_where = '';
$_like = '';
if (Validate::isArray($_param) && !Validate::isNullArray($_param)) {
$_limit = isset($_param['limit']) ? 'LIMIT ' . $_param['limit'] : '';
$_order = isset($_param['order']) ? 'ORDER BY ' . $_param['order'] : '';
$_where = '';
if (isset($_param['where'])) {
foreach ($_param['where'] as $_key => $_value) {
$_where .= $_value . ' AND ';
}
$_where = 'WHERE ' . substr($_where, 0, -4);
}
if (isset($_param['like'])) {
foreach ($_param['like'] as $_key => $_value) {
$_like = "WHERE {$_key} LIKE '%{$_value}%'";
}
}
}
$_selectFields = implode(',', $_field);
$_table = isset($_tables[1]) ? $_tables[0] . ',' . $_tables[1] : $_tables[0];
$_sql = "SELECT {$_selectFields} FROM {$_table} {$_where} {$_like} {$_order} {$_limit} ";
$_stmt = $this->execute($_sql);
$_result = array();
while (!!($_objs = $_stmt->fetchObject())) {
$_result[] = $_objs;
}
return Tool::setHtmlString($_result);
}