本文整理汇总了PHP中SSP::buildTable方法的典型用法代码示例。如果您正苦于以下问题:PHP SSP::buildTable方法的具体用法?PHP SSP::buildTable怎么用?PHP SSP::buildTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSP
的用法示例。
在下文中一共展示了SSP::buildTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: galleries_table
function galleries_table()
{
//ajax call function
if (!$_REQUEST) {
return false;
}
$baseSql = "\n\t\t\tSELECT \n\t\t\t\tCASE g.type \n\t\t\t\t\tWHEN 1 THEN 'Gallery 1'\n\t\t\t\t\tWHEN 2 THEN 'Gallery 2'\n\t\t\t\t\tWHEN 3 THEN 'Gallery 3'\n\t\t\t\t\tWHEN 4 THEN 'Gallery 4'\n\t\t\t\t\tELSE 'Gallery'\n\t\t\t\tEND AS 'Type',\n\t\t\t\tg.gallery_id,\n\t\t\t\tg.gallery_title as 'Title',\n\t\t\t\tg.url as 'URL',\n\t\t\t\tg.category as 'Category',\n\t\t\t\tg.author_id,\n\t\t\t\tg.created as 'Date Created',\n\t\t\t\tu.username as 'Author',\n\t\t\t\t'' as 'Image'\n\t\t\tFROM\n\t\t\t\tgallery g\n\t\t\tLEFT JOIN\n\t\t\t\tusername u\n\t\t\tON\n\t\t\t\tg.user_id = u.id\n\t\t";
//List all of your columns here
$columns = array('Title', 'URL', 'Type', 'Category', 'Author', 'Image', 'Date Created');
$functions = array();
/*
* adding functions is not required. This is just a way to run functions on the data if you wish.
* This will take the target which is the Image row from the query, and change it to the "replace" string.
* You can use part of the query to build the replace using {} and passing them in the params.
*/
$functions[] = array('function' => 'editRow', 'target' => 'Image', 'replace' => '<img src="www.mysite.com/{gallery_id}" alt="{Title}">', 'params' => array('gallery_id', 'Title'));
/*
* Add this to change the date format. Simply put in the date format
* of your column in the format_from value, and put the
* desired date format in the format_to value
* 20150101 becomes Thu: 01-01-15
*/
$functions[] = array('function' => 'date_format', 'format_to' => 'D: m-d-y', 'format_from' => 'Ymd', 'columns' => array('Date Created'));
/*
* list any columns you want to be "searchable".
* you can also list non visable data here to be searchable, such as the gallery_id.
*/
$searchable = array('Title', 'URL', 'Author', 'Category');
echo json_encode(SSP::buildTable($this->Model, $_REQUEST, $baseSql, $columns, $searchable, $functions));
}