本文整理汇总了PHP中plgFabrik_Element::toLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP plgFabrik_Element::toLabel方法的具体用法?PHP plgFabrik_Element::toLabel怎么用?PHP plgFabrik_Element::toLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plgFabrik_Element
的用法示例。
在下文中一共展示了plgFabrik_Element::toLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cacheAutoCompleteOptions
/**
* Cache method to populate auto-complete options
*
* @param plgFabrik_Element $elementModel Element model
* @param string $search Search string
* @param array $opts Options, 'label' => field to use for label (db join)
*
* @since 3.0.7
*
* @return string json encoded search results
*/
public static function cacheAutoCompleteOptions($elementModel, $search, $opts = array())
{
$listModel = $elementModel->getListModel();
$table = $listModel->getTable();
$db = $listModel->getDb();
$name = $elementModel->getFullName(false, false);
$query = $db->getQuery(true);
$params = $elementModel->getParams();
$format = $params->get('date_table_format');
$elementModel->strftimeTFormatToMySQL($format);
$search = $db->quote('%' . addslashes($search) . '%');
$query->select('DISTINCT(' . $name . ') AS value, ' . $name . ' AS text')->from($table->db_table_name)->where($name . ' LIKE ' . $search . ' OR DATE_FORMAT(' . $name . ', "' . $format . '" ) LIKE ' . $search);
$db->setQuery($query);
$tmp = $db->loadObjectList();
$ddData = array();
foreach ($tmp as &$t) {
$elementModel->toLabel($t->text);
if (!array_key_exists($t->text, $ddData)) {
$ddData[$t->text] = $t;
}
}
$ddData = array_values($ddData);
echo json_encode($ddData);
}
示例2: cacheAutoCompleteOptions
/**
* Cache method to populate autocomplete options
*
* @param plgFabrik_Element $elementModel element model
* @param string $search serch string
*
* @since 3.0.7
*
* @return string json encoded search results
*/
public static function cacheAutoCompleteOptions($elementModel, $search)
{
$name = $elementModel->getFullName(false, false, false);
$elementModel->encryptFieldName($name);
$listModel = $elementModel->getListModel();
$db = $listModel->getDb();
$query = $db->getQuery(true);
$tableName = $listModel->getTable()->db_table_name;
$query->select('DISTINCT(' . $name . ') AS value, ' . $name . ' AS text')->from($tableName);
$query->where($name . ' LIKE ' . $db->quote(addslashes('%' . $search . '%')));
$query = $listModel->_buildQueryJoin($query);
$query = $listModel->_buildQueryWhere(false, $query);
$query = $listModel->pluginQuery($query);
$db->setQuery($query);
$tmp = $db->loadObjectList();
foreach ($tmp as &$t) {
$elementModel->toLabel($t->text);
}
return json_encode($tmp);
}