本文整理汇总了PHP中db_list_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP db_list_fields函数的具体用法?PHP db_list_fields怎么用?PHP db_list_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_list_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
global $_zp_authority, $_userAddressFields;
$firstTime = false;
$tablecols = db_list_fields('administrators');
foreach ($tablecols as $key => $datum) {
if ($datum['Field'] == 'custom_data') {
$firstTime = true;
enableExtension('userAddressFields', true);
break;
}
}
parent::constructor('userAddressFields', self::fields());
if ($firstTime) {
// migrate the custom data user data
$result = query('SELECT * FROM ' . prefix('administrators') . ' WHERE `valid`!=0');
if ($result) {
while ($row = db_fetch_assoc($result)) {
$custom = getSerializedArray($row['custom_data']);
if (!empty($custom)) {
$sql = 'UPDATE ' . prefix('administrators') . ' SET ';
foreach ($custom as $field => $val) {
$sql .= '`' . $field . '`=' . db_quote($val) . ',';
}
setupQuery($sql);
}
}
db_free_result($result);
}
setupQuery('ALTER TABLE ' . prefix('administrators') . ' DROP `custom_data`');
}
$cloneid = bin2hex(FULLWEBPATH);
if (OFFSET_PATH == 2 && isset($_SESSION['admin'][$cloneid])) {
$user = unserialize($_SESSION['admin'][$cloneid]);
$user2 = $_zp_authority->getAnAdmin(array('`user`=' => $user->getUser(), '`pass`=' => $user->getPass(), '`valid`=' => 1));
if ($user2) {
foreach (userAddressFields::fields() as $field) {
$user2->set($field['name'], $user->get($field['name']));
}
$user2->save();
}
}
}
示例2: gettext
$check = -1;
}
if (empty($tableslist)) {
$msg = gettext('<em>SHOW TABLES</em> [found no tables]');
$msg2 = '';
} else {
$msg = sprintf(gettext("<em>SHOW TABLES</em> found: %s"), substr($tableslist, 0, -2));
$msg2 = '';
}
checkMark($check, $msg, gettext("<em>SHOW TABLES</em> [Failed]"), sprintf(gettext("The database did not return a list of the database tables for <code>%s</code>."), $_zp_conf_vars['mysql_database']) . "<br />" . gettext("<strong>Setup</strong> will attempt to create all tables. This will not over write any existing tables."));
if (isset($_zp_conf_vars['UTF-8']) && $_zp_conf_vars['UTF-8']) {
$fields = 0;
$fieldlist = array();
foreach (array('images' => 1, 'albums' => 2) as $lookat => $add) {
if (in_array($_zp_conf_vars['mysql_prefix'] . $lookat, $tables)) {
$columns = db_list_fields('images');
if ($columns) {
foreach ($columns as $col => $utf8) {
if (!is_null($row['Collation']) && $row['Collation'] != 'utf8_unicode_ci') {
$fields = $fields | $add;
$fieldlist[] = '<code>' . $lookat . '->' . $col . '</code>';
}
}
} else {
$fields = 4;
}
}
}
$err = -1;
switch ($fields) {
case 0:
示例3: searchFieldsAndTags
/**
* Searches the table for tags
* Returns an array of database records.
*
* @param string $searchstring
* @param string $tbl set to 'albums' or 'images'
* @param string $sorttype what to sort on
* @param string $sortdirection what direction
* @return array
*/
function searchFieldsAndTags($searchstring, $tbl, $sorttype, $sortdirection)
{
$allIDs = null;
$idlist = array();
$exact = EXACT_TAG_MATCH;
// create an array of [tag, objectid] pairs for tags
$tag_objects = array();
$fields = $this->fieldList;
if (count($fields) == 0) {
// then use the default ones
$fields = $this->allowedSearchFields();
}
foreach ($fields as $key => $field) {
if (strtolower($field) == 'tags') {
unset($fields[$key]);
$tagsql = 'SELECT t.`name`, o.`objectid` FROM ' . prefix('tags') . ' AS t, ' . prefix('obj_to_tag') . ' AS o WHERE t.`id`=o.`tagid` AND o.`type`="' . $tbl . '" AND (';
foreach ($searchstring as $singlesearchstring) {
switch ($singlesearchstring) {
case '&':
case '!':
case '|':
case '(':
case ')':
break;
default:
$targetfound = true;
if ($exact) {
$tagsql .= '`name` = ' . db_quote($singlesearchstring) . ' OR ';
} else {
$tagsql .= '`name` LIKE ' . db_quote('%' . $singlesearchstring . '%') . ' OR ';
}
}
}
$tagsql = substr($tagsql, 0, strlen($tagsql) - 4) . ') ORDER BY t.`id`';
$objects = query_full_array($tagsql, false);
if (is_array($objects)) {
$tag_objects = $objects;
}
break;
}
}
// create an array of [name, objectid] pairs for the search fields.
$field_objects = array();
if (count($fields) > 0) {
$columns = array();
$dbfields = db_list_fields($tbl);
if (is_array($dbfields)) {
foreach ($dbfields as $row) {
$columns[] = strtolower($row['Field']);
}
}
foreach ($searchstring as $singlesearchstring) {
switch ($singlesearchstring) {
case '&':
case '!':
case '|':
case '(':
case ')':
break;
default:
$targetfound = true;
query('SET @serachtarget=' . db_quote($singlesearchstring));
$fieldsql = '';
foreach ($fields as $fieldname) {
if ($tbl == 'albums' && $fieldname == 'filename') {
$fieldname = 'folder';
} else {
$fieldname = strtolower($fieldname);
}
if ($fieldname && in_array($fieldname, $columns)) {
$fieldsql .= ' `' . $fieldname . '` LIKE ' . db_quote('%' . $singlesearchstring . '%') . ' OR ';
}
}
if (!empty($fieldsql)) {
$fieldsql = substr($fieldsql, 0, strlen($fieldsql) - 4) . ') ORDER BY `id`';
$sql = 'SELECT @serachtarget AS name, `id` AS `objectid` FROM ' . prefix($tbl) . ' WHERE (' . $fieldsql;
$objects = query_full_array($sql, false);
if (is_array($objects)) {
$field_objects = array_merge($field_objects, $objects);
}
}
}
}
}
$objects = array_merge($tag_objects, $field_objects);
if (count($objects) != 0) {
$tagid = '';
$taglist = array();
foreach ($objects as $object) {
$tagid = strtolower($object['name']);
//.........这里部分代码省略.........
示例4: datepickerJS
datepickerJS();
codeblocktabsJS();
if (!isset($_GET['massedit']) && !isset($_GET['album']) || $subtab == 'subalbuminfo') {
printSortableHead();
}
if (isset($_GET['album']) && (empty($subtab) || $subtab == 'albuminfo') || isset($_GET['massedit'])) {
$result = db_list_fields('albums');
$dbfields = array();
if ($result) {
foreach ($result as $row) {
$dbfields[] = "'" . $row['Field'] . "'";
}
}
sort($dbfields);
$albumdbfields = implode(',', $dbfields);
$result = db_list_fields('images');
$dbfields = array();
if ($result) {
foreach ($result as $row) {
$dbfields[] = "'" . $row['Field'] . "'";
}
}
sort($dbfields);
$imagedbfields = implode(',', $dbfields);
?>
<script type="text/javascript" src="js/encoder.js"></script>
<script type="text/javascript" src="js/tag.js"></script>
<script type="text/javascript">
//<!-- <![CDATA[
var albumdbfields = [<?php
echo $albumdbfields;
示例5: while
while ($row = db_fetch_assoc($resource)) {
$result[] = $row;
}
db_free_result($resource);
} else {
$result = false;
}
$unique = $tables = array();
$table_cleared = array();
if (is_array($result)) {
foreach ($result as $row) {
extendExecution();
$table = array_shift($row);
$tables[$table] = array();
$table_cleared[$table] = false;
$result2 = db_list_fields(substr($table, $prefixLen));
if (is_array($result2)) {
foreach ($result2 as $row) {
$tables[$table][] = $row['Field'];
}
}
$result2 = db_show('index', $table);
if (is_array($result2)) {
foreach ($result2 as $row) {
if (is_array($row)) {
if (array_key_exists('Non_unique', $row) && !$row['Non_unique']) {
$unique[$table][] = $row['Column_name'];
}
}
}
}
示例6: lookupSortKey
/**
* Returns a sort field part for querying
* Note: $sorttype may be a comma separated list of field names. If so,
* these are peckmarked and returned otherwise unchanged.
*
* @param string $sorttype the 'Display" name of the sort
* @param string $default the default if $sorttype is empty
* @param string $table the database table being used.
* @return string
*/
function lookupSortKey($sorttype, $default, $table)
{
global $_zp_fieldLists;
switch (strtolower($sorttype)) {
case 'random':
return 'RAND()';
case "manual":
return 'sort_order';
default:
if (empty($sorttype)) {
if (empty($default)) {
return 'id';
}
return $default;
}
if (substr($sorttype, 0) == '(') {
return $sorttype;
}
if ($table == 'albums') {
// filename is synonomon for folder with albums
$sorttype = str_replace('filename', 'folder', $sorttype);
}
if (is_array($_zp_fieldLists) && isset($_zp_fieldLists[$table])) {
$dbfields = $_zp_fieldLists[$table];
} else {
$result = db_list_fields($table);
$dbfields = array();
if ($result) {
foreach ($result as $row) {
$dbfields[strtolower($row['Field'])] = $row['Field'];
}
}
$_zp_fieldLists[$table] = $dbfields;
}
$sorttype = strtolower($sorttype);
$list = explode(',', $sorttype);
$rslt = array();
foreach ($list as $key => $field) {
if (array_key_exists($field = trim($field, '`'), $dbfields)) {
$rslt[] = '`' . trim($dbfields[$field]) . '`';
}
}
if (empty($rslt)) {
return 'id';
}
return implode(',', $rslt);
}
}
示例7: constructor
/**
*
* This method establishes the current set of database fields. It will add the
* fields to the database if they are not already present. Fields from previous
* constructor calls that are no longer in the list will be removed from the
* database (along with any data associated with them.)
*
* @param array $newfields
*/
function constructor($me, $newfields)
{
$database = array();
foreach (getDBTables() as $table) {
$tablecols = db_list_fields($table);
foreach ($tablecols as $key => $datum) {
$database[$table][$datum['Field']] = $datum;
}
}
$current = $fields = $searchDefault = array();
if (extensionEnabled($me)) {
//need to update the database tables.
foreach ($newfields as $newfield) {
$table = $newfield['table'];
$name = $newfield['name'];
if (!($existng = isset($database[$table][$name]))) {
if (isset($newfield['searchDefault']) && $newfield['searchDefault']) {
$searchDefault[] = $name;
}
}
if (is_null($newfield['type'])) {
if ($name == 'tags') {
setOption('adminTagsTab', 1);
}
} else {
switch (strtolower($newfield['type'])) {
default:
$dbType = strtoupper($newfield['type']);
break;
case 'int':
$dbType = strtoupper($newfield['type']) . '(' . min(255, $newfield['size']) . ')';
if (isset($newfield['attribute'])) {
$dbType .= ' ' . $newfield['attribute'];
unset($newfield['attribute']);
}
break;
case 'varchar':
$dbType = strtoupper($newfield['type']) . '(' . min(255, $newfield['size']) . ')';
break;
}
if ($existng) {
if (strtoupper($database[$table][$name]['Type']) != $dbType || empty($database[$table][$name]['Comment'])) {
$cmd = ' CHANGE `' . $name . '`';
} else {
$cmd = NULL;
}
unset($database[$table][$name]);
} else {
$cmd = ' ADD COLUMN';
}
$sql = 'ALTER TABLE ' . prefix($newfield['table']) . $cmd . ' `' . $name . '` ' . $dbType;
if (isset($newfield['attribute'])) {
$sql .= ' ' . $newfield['attribute'];
}
if (isset($newfield['default'])) {
$sql .= ' DEFAULT ' . $newfield['default'];
}
$sql .= " COMMENT 'optional_{$me}'";
if ((!$cmd || setupQuery($sql)) && in_array($newfield['table'], array('albums', 'images', 'news', 'news_categories', 'pages'))) {
$fields[] = strtolower($newfield['name']);
}
$current[$newfield['table']][$newfield['name']] = $dbType;
}
}
setOption(get_class($this) . '_addedFields', serialize($current));
if (!empty($searchDefault)) {
$fieldExtenderMutex = new zpMutex('fE');
$fieldExtenderMutex->lock();
$engine = new SearchEngine();
$set_fields = $engine->allowedSearchFields();
$set_fields = array_unique(array_merge($set_fields, $searchDefault));
setOption('search_fields', implode(',', $set_fields));
$fieldExtenderMutex->unlock();
}
} else {
purgeOption(get_class($this) . '_addedFields');
}
foreach ($database as $table => $fields) {
//drop fields no longer defined
foreach ($fields as $field => $orphaned) {
if ($orphaned['Comment'] == "optional_{$me}") {
$sql = 'ALTER TABLE ' . prefix($table) . ' DROP `' . $field . '`';
setupQuery($sql);
}
}
}
}
示例8: printAdminHeader
}
}
printAdminHeader($_current_tab);
?>
<script type="text/javascript" src="js/farbtastic.js"></script>
<link rel="stylesheet" href="js/farbtastic.css" type="text/css" />
<?php
if ($_zp_admin_subtab == 'gallery' || $_zp_admin_subtab == 'image') {
if ($_zp_admin_subtab == 'image') {
$table = 'images';
$targetid = 'customimagesort';
} else {
$table = 'albums';
$targetid = 'customalbumsort';
}
$result = db_list_fields($table);
$dbfields = array();
if ($result) {
foreach ($result as $row) {
$dbfields[] = "'" . $row['Field'] . "'";
}
sort($dbfields);
}
?>
<script type="text/javascript" src="js/encoder.js"></script>
<script type="text/javascript" src="js/tag.js"></script>
<script type="text/javascript">
// <!-- <![CDATA[
$(function () {
$('#<?php
echo $targetid;
示例9: searchFieldsAndTags
/**
* Searches the table for tags
* Returns an array of database records.
*
* @param array $searchstring
* @param string $tbl set DB table name to be searched
* @param string $sorttype what to sort on
* @param string $sortdirection what direction
* @return array
*/
protected function searchFieldsAndTags($searchstring, $tbl, $sorttype, $sortdirection)
{
global $_zp_gallery;
$weights = $idlist = array();
$sql = $allIDs = NULL;
$tagPattern = $this->tagPattern;
// create an array of [tag, objectid] pairs for tags
$tag_objects = array();
$fields = $this->fieldList;
if (count($fields) == 0) {
// then use the default ones
$fields = $this->allowedSearchFields();
}
foreach ($fields as $key => $field) {
switch ($field) {
case 'news_categories':
if ($tbl != 'news') {
break;
}
unset($fields[$key]);
query('SET @serachfield="news_categories"');
$tagsql = 'SELECT @serachfield AS field, t.`title` AS name, o.`news_id` AS `objectid` FROM ' . prefix('news_categories') . ' AS t, ' . prefix('news2cat') . ' AS o WHERE t.`id`=o.`cat_id` AND (';
foreach ($searchstring as $singlesearchstring) {
switch ($singlesearchstring) {
case '&':
case '!':
case '|':
case '(':
case ')':
break;
case '*':
$targetfound = true;
$tagsql .= "COALESCE(title, '') != '' OR ";
break;
default:
$targetfound = true;
$tagsql .= '`title` = ' . db_quote($singlesearchstring) . ' OR ';
}
}
$tagsql = substr($tagsql, 0, strlen($tagsql) - 4) . ') ORDER BY t.`id`';
$objects = query_full_array($tagsql, false);
if (is_array($objects)) {
$tag_objects = $objects;
}
break;
case 'tags_exact':
$tagPattern = array('type' => '=', 'open' => '', 'close' => '');
case 'tags':
unset($fields[$key]);
query('SET @serachfield="tags"');
$tagsql = 'SELECT @serachfield AS field, t.`name`, o.`objectid` FROM ' . prefix('tags') . ' AS t, ' . prefix('obj_to_tag') . ' AS o WHERE t.`id`=o.`tagid` AND o.`type`="' . $tbl . '" AND (';
foreach ($searchstring as $singlesearchstring) {
switch ($singlesearchstring) {
case '&':
case '!':
case '|':
case '(':
case ')':
break;
case '*':
query('SET @emptyfield="*"');
$tagsql = str_replace('t.`name`', '@emptyfield as name', $tagsql);
$tagsql .= "t.`name` IS NOT NULL OR ";
break;
default:
$targetfound = true;
if ($tagPattern['type'] == 'like') {
$target = db_LIKE_escape($singlesearchstring);
} else {
$target = $singlesearchstring;
}
$tagsql .= 't.`name` ' . strtoupper($tagPattern['type']) . ' ' . db_quote($tagPattern['open'] . $target . $tagPattern['close']) . ' OR ';
}
}
$tagsql = substr($tagsql, 0, strlen($tagsql) - 4) . ') ORDER BY t.`id`';
$objects = query_full_array($tagsql, false);
if (is_array($objects)) {
$tag_objects = array_merge($tag_objects, $objects);
}
break;
default:
break;
}
}
// create an array of [name, objectid] pairs for the search fields.
$field_objects = array();
if (count($fields) > 0) {
$columns = array();
$dbfields = db_list_fields($tbl);
if (is_array($dbfields)) {
//.........这里部分代码省略.........
示例10: array
if ($resource) {
$result = array();
while ($row = db_fetch_assoc($resource)) {
$result[] = $row;
}
} else {
$result = false;
}
$tables = array();
$table_cleared = array();
if (is_array($result)) {
foreach ($result as $row) {
$table = array_shift($row);
$tables[$table] = array();
$table_cleared[$table] = false;
$result2 = db_list_fields(str_replace($prefix, '', $table));
if (is_array($result2)) {
foreach ($result2 as $row) {
$tables[$table][] = $row['Field'];
}
}
}
}
$success = 0;
$string = getrow($handle);
while (substr($string, 0, strlen(HEADER)) == HEADER) {
$string = substr($string, strlen(HEADER));
$i = strpos($string, '=');
$type = substr($string, 0, $i);
$what = substr($string, $i + 1);
switch ($type) {
示例11: str_replace
echo str_replace($prefix, '', $table);
?>
</a></h3>
<table id = "t_<?php
echo $i;
?>
" class="bordered" <?php
if ($i > 1) {
?>
style="display: none;" <?php
}
?>
>
<tr>
<?php
$cols = $tablecols = db_list_fields(str_replace($prefix, '', $table), true);
$cols = array_shift($cols);
foreach ($cols as $col => $value) {
?>
<th><?php
echo $col;
?>
</th>
<?php
}
?>
</tr>
<?php
//echo "<pre>"; print_r($tablecols); echo "</pre>";
$rowcount = 0;
foreach ($tablecols as $col) {
示例12: array
$fieldlist = array();
if (strpos($tableslist, $_zp_conf_vars['mysql_prefix'] . 'images') !== false) {
$columns = db_list_fields('images');
if ($columns) {
foreach ($columns as $col => $utf8) {
if (!is_null($row['Collation']) && $row['Collation'] != 'utf8_unicode_ci') {
$fields = $fields | 1;
$fieldlist[] = '<code>images->' . $col . '</code>';
}
}
} else {
$fields = 4;
}
}
if (strpos($tableslist, $_zp_conf_vars['mysql_prefix'] . 'albums') !== false) {
$columns = db_list_fields('albums');
if ($columns) {
foreach ($columns as $col => $utf8) {
if (!is_null($row['Collation']) && $row['Collation'] != 'utf8_unicode_ci') {
$fields = $fields | 2;
$fieldlist[] = '<code>albums->' . $col . '</code>';
}
}
} else {
$fields = 4;
}
}
$err = -1;
switch ($fields) {
case 0:
// all is well
示例13: lookupSortKey
/**
* Returns a sort field part for querying
* Note: $sorttype may be a comma separated list of field names. If so,
* these are peckmarked and returned otherwise unchanged.
*
* @param string $sorttype the 'Display" name of the sort
* @param string $default the default if $sorttype is empty
* @param string $table the database table being used.
* @return string
*/
function lookupSortKey($sorttype, $default, $table)
{
global $_zp_fieldLists;
switch (strtolower($sorttype)) {
case 'random':
return 'RAND()';
case "manual":
return 'sort_order';
case "filename":
switch ($table) {
case 'images':
return 'filename';
case 'albums':
return 'folder';
}
default:
if (empty($sorttype)) {
return $default;
}
if (substr($sorttype, 0) == '(') {
return $sorttype;
}
if (is_array($_zp_fieldLists) && isset($_zp_fieldLists[$table])) {
$dbfields = $_zp_fieldLists[$table];
} else {
$result = db_list_fields($table);
$dbfields = array();
if ($result) {
foreach ($result as $row) {
$dbfields[strtolower($row['Field'])] = $row['Field'];
}
}
$_zp_fieldLists[$table] = $dbfields;
}
$sorttype = strtolower($sorttype);
$list = explode(',', $sorttype);
$fields = array();
// Critical for preventing SQL injection: only return parts of
// the custom sort that are exactly equal to database fields.
foreach ($list as $key => $field) {
$field = trim($field);
if (array_key_exists($field, $dbfields)) {
$fields[$key] = trim($dbfields[$field]);
}
}
return implode(',', $fields);
}
}
示例14: __construct
function __construct()
{
if (OFFSET_PATH == 2) {
$present = array('albums' => 0, 'images' => 0, 'news' => 0, 'pages' => 0, 'news_categories' => 0);
foreach ($present as $table => $v) {
$tablecols = db_list_fields($table);
foreach ($tablecols as $key => $datum) {
if ($datum['Field'] == 'custom_data') {
$present[$table] = 1 + (int) (!empty($datum['Comment']));
}
}
}
if (extensionEnabled('customdata')) {
setOptionDefault('customDataAlbums', $present['albums']);
setOptionDefault('customDataImages', $present['images']);
setOptionDefault('customDataNews', $present['news']);
setOptionDefault('customDataPages', $present['pages']);
setOptionDefault('customDataCategories', $present['news_categories']);
} else {
purgeOption('customDataAlbums');
purgeOption('customDataImages');
purgeOption('customDataNews');
purgeOption('customDataPages');
purgeOption('customDataCategories');
}
if (getOption('customDataAlbums')) {
if (!$present['albums']) {
setupQuery('ALTER TABLE ' . prefix('albums') . " ADD COLUMN `custom_data` TEXT COMMENT 'optional_customData'");
}
} else {
if ($present['albums']) {
setupQuery('ALTER TABLE ' . prefix('albums') . ' DROP `custom_data`');
}
}
if (getOption('customDataImages')) {
if (!$present['images']) {
setupQuery('ALTER TABLE ' . prefix('images') . " ADD COLUMN `custom_data` TEXT COMMENT 'optional_customData'");
}
} else {
if ($present['images']) {
setupQuery('ALTER TABLE ' . prefix('images') . ' DROP `custom_data`');
}
}
if (getOption('customDataNews')) {
if (!$present['news']) {
setupQuery('ALTER TABLE ' . prefix('news') . " ADD COLUMN `custom_data` TEXT COMMENT 'optional_customData'");
}
} else {
if ($present['news']) {
setupQuery('ALTER TABLE ' . prefix('news') . ' DROP `custom_data`');
}
}
if (getOption('customDataPages')) {
if (!$present['pages']) {
setupQuery('ALTER TABLE ' . prefix('pages') . " ADD COLUMN `custom_data` TEXT COMMENT 'optional_customData'");
}
} else {
if ($present['pages']) {
setupQuery('ALTER TABLE ' . prefix('pages') . ' DROP `custom_data`');
}
}
if (getOption('customDataCategories')) {
if (!$present['news_categories']) {
setupQuery('ALTER TABLE ' . prefix('news_categories') . " ADD COLUMN `custom_data` TEXT COMMENT 'optional_customData'");
}
} else {
if ($present['news_categories']) {
setupQuery('ALTER TABLE ' . prefix('news_categories') . ' DROP `custom_data`');
}
}
}
}
示例15: lookupSortKey
/**
* Returns a sort field part for querying
* Note: $sorttype may be a comma separated list of field names. If so,
* these are peckmarked and returned otherwise unchanged.
*
* @param string $sorttype the 'Display" name of the sort
* @param string $default the default if $sorttype is empty
* @param string $table the database table being used.
* @return string
*/
function lookupSortKey($sorttype, $default, $table)
{
global $_zp_fieldLists;
switch (strtolower($sorttype)) {
case 'random':
return 'RAND()';
case "manual":
return '`sort_order`';
case "filename":
switch ($table) {
case 'images':
return '`filename`';
case 'albums':
return '`folder`';
}
default:
if (empty($sorttype)) {
return '`' . $default . '`';
}
if (substr($sorttype, 0) == '(') {
return $sorttype;
}
if (is_array($_zp_fieldLists) && isset($_zp_fieldLists[$table])) {
$dbfields = $_zp_fieldLists[$table];
} else {
$result = db_list_fields($table);
$dbfields = array();
if ($result) {
foreach ($result as $row) {
$dbfields[strtolower($row['Field'])] = $row['Field'];
}
}
$_zp_fieldLists[$table] = $dbfields;
}
$sorttype = strtolower($sorttype);
$list = explode(',', $sorttype);
foreach ($list as $key => $field) {
if (array_key_exists($field, $dbfields)) {
$list[$key] = '`' . trim($dbfields[$field]) . '`';
}
}
return implode(',', $list);
}
}