本文整理汇总了PHP中DBUtil::getColumnsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::getColumnsArray方法的具体用法?PHP DBUtil::getColumnsArray怎么用?PHP DBUtil::getColumnsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::getColumnsArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslations
public function getTranslations($args)
{
$pageId = (int) $args['pageId'];
$table = DBUtil::getTables();
$translatedTable = $table['content_translatedcontent'];
$translatedColumn = $table['content_translatedcontent_column'];
$contentTable = $table['content_content'];
$contentColumn = $table['content_content_column'];
$cols = DBUtil::_getAllColumns('content_translatedcontent');
$ca = DBUtil::getColumnsArray('content_translatedcontent');
$sql = "\n SELECT {$cols}\n FROM {$translatedTable} t\n LEFT JOIN {$contentTable} c\n ON c.{$contentColumn['id']} = t.{$translatedColumn['contentId']}\n WHERE c.{$contentColumn['pageId']} = {$pageId}";
$dbresult = DBUtil::executeSQL($sql);
$translations = DBUtil::marshallObjects($dbresult, $ca);
return $translations;
}
示例2: exportaTaula
/**
* Exporta els registres de la taula seleccionada a un fitxer csv
*
*
* @return void (carrega la plantilla per importar/exportar taules)
*/
public function exportaTaula() {
// Security check
//$this->checkCsrfToken();
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN));
if ($this->request->isPost()) {
$taula = $this->request->request->get('taula_exp', false);
}
if (is_null($taula)) {
LogUtil::registerError(__('L\'exportació de dades no és possible. No s\'ha especificat cap taula.'));
} else {
$titlerow = DBUtil::getColumnsArray($taula);
$datarows = DBUtil::selectObjectArray($taula);
$date = date('_Ymd_Hi');
FileUtil::exportCSV($datarows, $titlerow, ';', '"', $taula . $date . '.csv');
}
// Després de exportCSV no executa aquest redirect
//return system::redirect(ModUtil::url('Llicencies', 'admin', 'ieTables#tabs-2'));
$this->redirect(ModUtil::url('llicencies', 'admin', 'ieTables'));
}
示例3: exportGtafEntities
/**
* Exporta un csv amb tota la informació de les entitats-gtaf/grups d'entitats-gtaf que té Sirius
*
*
* @return void Retorna a la funció *gtafEntitiesGest* amb els missatges d'execució
*/
public function exportGtafEntities() {
if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
$case = FormUtil::getPassedValue('case',null,'GET');
if ($case == 'entities') {
$taula = 'cataleg_gtafEntities';
$fitxer = 'exportaGtafEntitats.csv';
} elseif ($case == 'groups') {
$taula = 'cataleg_gtafGroups';
$fitxer = 'exportaGtafGrups.csv';
} else {
LogUtil::registerError($this->__('La petició no és vàlida'));
return system::redirect(ModUtil::url('Cataleg', 'admin', 'gtafEntitiesGest'));
}
$titlerow = DBUtil::getColumnsArray($taula);
$datarows = DBUtil::selectObjectArray($taula);
FileUtil::exportCSV($datarows, $titlerow, ';', '"', $fitxer);
return system::redirect(ModUtil::url('Cataleg', 'admin', 'gtafEntitiesGest'));
}
示例4: contentUpgrade_4_1_2
protected function contentUpgrade_4_1_2($oldVersion)
{
$dbtables = DBUtil::getTables();
$searchableTable = $dbtables['content_searchable'];
$searchableColumn = $dbtables['content_searchable_column'];
// add new primary key field and a language field
$sql = 'ALTER TABLE `' . $searchableTable . '` CHANGE `search_cid` `search_cid` INT(11) NOT NULL;';
if (!DBUtil::executeSQL($sql)) {
return LogUtil::registerError($this->__('Error! Could not update searchable table (1).'));
}
$sql = 'ALTER TABLE `' . $searchableTable . '` DROP PRIMARY KEY;';
if (!DBUtil::executeSQL($sql)) {
return LogUtil::registerError($this->__('Error! Could not update searchable table (2).'));
}
$sql = 'ALTER TABLE `' . $searchableTable . '` ADD `search_sid` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT FIRST;';
if (!DBUtil::executeSQL($sql)) {
return LogUtil::registerError($this->__('Error! Could not update searchable table (3).'));
}
$sql = 'ALTER TABLE `' . $searchableTable . '` ADD `search_language` VARCHAR(10) NOT NULL AFTER `search_text`;';
if (!DBUtil::executeSQL($sql)) {
return LogUtil::registerError($this->__('Error! Could not update searchable table (4).'));
}
// update existing searchable data setting the default language code
$defaultLanguage = System::getVar('language_i18n');
$sql = "UPDATE `{$searchableTable}` SET `search_language` = '{$defaultLanguage}';";
if (!DBUtil::executeSQL($sql)) {
return LogUtil::registerError($this->__('Error! Could not update searchable table (5).'));
}
// check if we need to insert searchable rows for existing translations
$multilingual = System::getVar('multilingual');
if ($multilingual) {
// retrieve existing translation languages
$contentTable = $dbtables['content_content'];
$contentColumn = $dbtables['content_content_column'];
$translatedTable = $dbtables['content_translatedcontent'];
$translatedColumn = $dbtables['content_translatedcontent_column'];
$sql = "\n SELECT DISTINCT {$translatedColumn['language']}\n FROM {$translatedTable} t";
$dbresult = DBUtil::executeSQL($sql);
$languages = DBUtil::marshallObjects($dbresult);
$cols = DBUtil::_getAllColumns('content_content');
$ca = DBUtil::getColumnsArray('content_content');
$ca[] = 'translated';
// iterate translations
foreach ($languages as $language) {
// exclude the default language, since a page could have been created using another default language
if ($language == $defaultLanguage) {
continue;
}
// get all translations for this language
$sql = "\n SELECT {$cols}, {$translatedColumn['data']} AS translated\n FROM {$contentTable} c\n LEFT JOIN {$translatedTable} t\n AND t.{$translatedColumn['language']} = '{$language}'";
$dbresult = DBUtil::executeSQL($sql);
$content = DBUtil::marshallObjects($dbresult, $ca);
$view = Zikula_View::getInstance('Content');
$contentApi = new Content_Api_Content(ServiceUtil::getManager());
for ($i = 0, $cou = count($content); $i < $cou; ++$i) {
$c =& $content[$i];
$c['data'] = empty($c['data']) ? null : unserialize($c['data']);
$c['translated'] = empty($c['translated']) ? null : unserialize($c['translated']);
// set translation as plugin content
if (is_array($c['translated']) && is_array($c['data'])) {
$c['data'] = array_merge($c['data'], $c['translated']);
}
// get access to the content plugin
$contentPlugin = $contentApi->getContentPlugin($c, $view);
// check if content is translatable
if (!$contentPlugin || !$contentPlugin->isTranslatable()) {
continue;
}
// extract searchable text
$text = $contentPlugin->getSearchableText();
// insert into searchable table
$searchObj = array('contentId' => $c['id'], 'text' => $text, 'language' => $language);
DBUtil::insertObject($searchObj, 'content_searchable', 'searchableId');
}
}
}
return true;
}
示例5: MostCommentsBlock_getall
public function MostCommentsBlock_getall($args = array())
{
if (!isset($args['numitems']) || !is_numeric($args['numitems'])) {
$args['numitems'] = -1;
}
// Security check
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_OVERVIEW)) {
return array();
}
// Get database setup
$pntable = pnDBGetTables();
$table = $pntable['EZComments'];
$columns =& $pntable['EZComments_column'];
// form where clause
$whereclause = array();
if (isset($args['mod'])) {
$whereclause[] = "{$columns['modname']} = '" . DataUtil::formatForStore($args['mod']) . "'";
}
// create where clause
$where = '';
if (!empty($whereclause)) {
$where = implode(' AND ', $whereclause) . ' and ';
}
$permFilter[] = array('component_left' => 'EZComments', 'component_middle' => '', 'component_right' => '', 'instance_left' => 'modname', 'instance_middle' => 'objectid', 'instance_right' => 'id', 'level' => ACCESS_READ);
$cols = DBUtil::_getAllColumns('EZComments');
// FIXME: don't need all
$ca = DBUtil::getColumnsArray('EZComments');
$ca[] = "count";
$sql = "\n SELECT DISTINCT\n {$cols},\n count(*) as count\n FROM {$table}\n where {$where} {$columns['status']} = 0\n group by {$columns['modname']},{$columns['objectid']}\n order by count desc\n ";
$dbresult = DBUtil::executeSQL($sql, 0, $args['numitems']);
$items = DBUtil::marshallObjects($dbresult, $ca);
// backwards compatibilty: modname -> mod
foreach (array_keys($items) as $k) {
$items[$k]['mod'] = $items[$k]['modname'];
}
// return the items
return $items;
}
示例6: getPages
/**
* Get a list of pages
*
* This function returns an array of pages depending on the various parameters. The most
* interesting parameter may be "filter" which contains all the restrictions on the list.
* The filter data is passed to contentGetPageListRestrictions() which is where you
* will find the documentation.
*
* @param filter array See contentGetPageListRestrictions().
* @param orderBy string Field for "order by" in SQL query
* @param orderDir string Direction for "order by" in SQL query (desc/asc) default: asc
* @param pageIndex int Zero based page index for browsing page by page.
* @param pageSize int Number of pages to show on each "page".
* @param language string Three letter language identifier used for translating content.
* @param translate bool Enable translation.
* @param makeTree bool Enable conversion of page list to recursive tree structure.
* @param includeContent bool Enable inclusion of content items.
* @param includeCategories bool Enable inclusion of secondary category data.
* @param includeLanguages bool Enable inclusion of list of translated languages (array('dan','eng')).
* @param editing bool Passed to content plugins to enable "edit" display (as opposed to normal user display).
*
* @return array Array of pages (each of which is an associative array).
*/
public function getPages($args)
{
$filter = isset($args['filter']) ? $args['filter'] : array();
$orderBy = !empty($args['orderBy']) ? $args['orderBy'] : 'cr_date';
$orderDir = !empty($args['orderDir']) ? $args['orderDir'] : 'asc';
$pageIndex = isset($args['pageIndex']) ? $args['pageIndex'] : 0;
$pageSize = isset($args['pageSize']) ? $args['pageSize'] : 0;
$language = (array_key_exists('language', $args) ? $args['language'] : ZLanguage::getLanguageCode());
$translate = (array_key_exists('translate', $args) ? $args['translate'] : true);
$makeTree = (array_key_exists('makeTree', $args) ? $args['makeTree'] : false);
$includeLayout = (array_key_exists('includeLayout', $args) ? $args['includeLayout'] : true);
$includeContent = (array_key_exists('includeContent', $args) ? $args['includeContent'] : false);
$expandContent = (array_key_exists('expandContent', $args) ? $args['expandContent'] : true);
$includeCategories = (array_key_exists('includeCategories', $args) ? $args['includeCategories'] : false);
$includeVersionNo = (array_key_exists('includeVersionNo', $args) ? $args['includeVersionNo'] : false);
$editing = (array_key_exists('editing', $args) ? $args['editing'] : false);
$dbtables = DBUtil::getTables();
$pageTable = $dbtables['content_page'];
$pageColumn = $dbtables['content_page_column'];
//$pageCategoryTable = $dbtables['content_pagecategory'];
//$pageCategoryColumn = $dbtables['content_pagecategory_column'];
$translatedTable = $dbtables['content_translatedpage'];
$translatedColumn = $dbtables['content_translatedpage_column'];
$userTable = $dbtables['users'];
$userColumn = $dbtables['users_column'];
$restrictions = array();
$join = '';
$this->contentGetPageListRestrictions($filter, $restrictions, $join);
if (count($restrictions) > 0) {
$where = 'WHERE ' . join(' AND ', $restrictions);
} else {
$where = '';
}
if (!empty($orderBy)) {
$orderBy = ' ORDER BY ' . DataUtil::formatForStore($orderBy);
$orderBy .= $orderDir == 'desc' ? ' DESC' : ' ASC';
}
$language = DataUtil::formatForStore($language);
$cols = DBUtil::_getAllColumns('content_page');
$ca = DBUtil::getColumnsArray('content_page');
$ca[] = 'translatedTitle';
$ca[] = 'translatedMetaDescription';
$ca[] = 'translatedMetaKeywords';
$ca[] = 'uname';
$sql = "
SELECT DISTINCT
$cols,
$translatedColumn[title],
$translatedColumn[metadescription],
$translatedColumn[metakeywords],
$userColumn[uname]
FROM $pageTable
LEFT JOIN $translatedTable t
ON t.$translatedColumn[pageId] = $pageColumn[id]
AND t.$translatedColumn[language] = '$language'
LEFT JOIN $userTable usr
ON usr.$userColumn[uid] = $pageColumn[lu_uid]
$join
$where
$orderBy";
if ($pageSize > 0) {
$dbresult = DBUtil::executeSQL($sql, $pageSize * $pageIndex, $pageSize);
} else {
$dbresult = DBUtil::executeSQL($sql);
}
$pages = DBUtil::marshallObjects($dbresult, $ca);
//.........这里部分代码省略.........
示例7: getTranslations
public function getTranslations($args)
{
$pageId = (int) $args['pageId'];
$table = DBUtil::getTables();
$translatedTable = $table['content_translatedcontent'];
$translatedColumn = $table['content_translatedcontent_column'];
$contentTable = $table['content_content'];
$contentColumn = $table['content_content_column'];
$cols = DBUtil::_getAllColumns('content_translatedcontent');
$ca = DBUtil::getColumnsArray('content_translatedcontent');
$sql = "
SELECT $cols
FROM $translatedTable t
LEFT JOIN $contentTable c
ON c.$contentColumn[id] = t.$translatedColumn[contentId]
WHERE c.$contentColumn[pageId] = $pageId";
$dbresult = DBUtil::executeSQL($sql);
$translations = DBUtil::marshallObjects($dbresult, $ca);
return $translations;
}