本文整理汇总了PHP中DBUtil::getResultArray方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::getResultArray方法的具体用法?PHP DBUtil::getResultArray怎么用?PHP DBUtil::getResultArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::getResultArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_main
function do_main()
{
$this->oPage->setBreadcrumbDetails(_kt("transactions"));
$this->oPage->setTitle(_kt('Folder transactions'));
$folder_data = array();
$folder_data["folder_id"] = $this->oFolder->getId();
$this->oPage->setSecondaryTitle($this->oFolder->getName());
$aTransactions = array();
// FIXME do we really need to use a raw db-access here? probably...
$sQuery = "SELECT DTT.name AS transaction_name, FT.transaction_namespace, U.name AS user_name, FT.comment AS comment, FT.datetime AS datetime " . "FROM " . KTUtil::getTableName("folder_transactions") . " AS FT LEFT JOIN " . KTUtil::getTableName("users") . " AS U ON FT.user_id = U.id " . "LEFT JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = FT.transaction_namespace " . "WHERE FT.folder_id = ? ORDER BY FT.datetime DESC";
$aParams = array($this->oFolder->getId());
$res = DBUtil::getResultArray(array($sQuery, $aParams));
if (PEAR::isError($res)) {
var_dump($res);
// FIXME be graceful on failure.
exit(0);
}
// FIXME roll up view transactions
$aTransactions = $res;
// Set the namespaces where not in the transactions lookup
foreach ($aTransactions as $key => $transaction) {
if (empty($transaction['transaction_name'])) {
$aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']);
}
}
// render pass.
$this->oPage->title = _kt("Folder History");
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate("kt3/view_folder_history");
$aTemplateData = array("context" => $this, "folder_id" => $folder_id, "folder" => $this->oFolder, "transactions" => $aTransactions);
return $oTemplate->render($aTemplateData);
}
示例2: do_main
function do_main()
{
$this->oPage->setSecondaryTitle($this->oDocument->getName());
$this->oPage->setBreadcrumbDetails(_kt('history'));
$aTransactions = array();
// FIXME create a sane "view user information" page somewhere.
// FIXME do we really need to use a raw db-access here? probably...
$sQuery = 'SELECT DTT.name AS transaction_name, DT.transaction_namespace, U.name AS user_name, DT.version AS version, DT.comment AS comment, DT.datetime AS datetime ' . 'FROM ' . KTUtil::getTableName('document_transactions') . ' AS DT INNER JOIN ' . KTUtil::getTableName('users') . ' AS U ON DT.user_id = U.id ' . 'LEFT JOIN ' . KTUtil::getTableName('transaction_types') . ' AS DTT ON DTT.namespace = DT.transaction_namespace ' . 'WHERE DT.document_id = ? ORDER BY DT.datetime DESC';
$aParams = array($this->oDocument->getId());
$res = DBUtil::getResultArray(array($sQuery, $aParams));
if (PEAR::isError($res)) {
var_dump($res);
// FIXME be graceful on failure.
exit(0);
}
$aTransactions = $res;
// Set the namespaces where not in the transactions lookup
foreach ($aTransactions as $key => $transaction) {
if (empty($transaction['transaction_name'])) {
$aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']);
}
}
// render pass.
$this->oPage->setTitle(_kt('Document History'));
$oTemplate = $this->oValidator->validateTemplate('ktcore/document/transaction_history');
$aTemplateData = array('context' => $this, 'document_id' => $this->oDocument->getId(), 'document' => $this->oDocument, 'transactions' => $aTransactions);
return $oTemplate->render($aTemplateData);
}
示例3: getSettings
/**
* Get the configuration settings
*
* @return array
*/
function getSettings()
{
$query = "SELECT g.display_name AS group_display, g.description AS group_description,\n s.id, s.display_name, s.description, s.value, s.default_value, s.type, s.options\n FROM config_groups g\n INNER JOIN config_settings s ON g.name = s.group_name\n WHERE category = '{$this->category}' AND s.can_edit = 1\n ORDER BY g.name, s.item";
$results = DBUtil::getResultArray($query);
if (PEAR::isError($results)) {
$this->addErrorMessage(sprintf(_kt("The configuration settings could not be retrieved: %s"), $results->getMessage()));
return array();
}
return $results;
}
示例4: postValidate
function postValidate()
{
global $default;
$document =& $this->aInfo["document"];
$documentid = $document->getId();
$sql = "SELECT document_id FROM search_saved_events WHERE document_id={$documentid}";
$rs = DBUtil::getResultArray($sql);
if (count($rs) == 0) {
$sql = "INSERT INTO search_saved_events (document_id) VALUES ({$documentid})";
DBUtil::runQuery($sql);
}
}
示例5: getSupportedMimeTypesDB
function getSupportedMimeTypesDB($sExtractorName)
{
$sQuery = "SELECT MT.mimetypes FROM mime_extractors as ME LEFT JOIN mime_types as MT ON " . "(ME.id = MT.extractor_id) WHERE ME.name = ?";
$aQuery = array($sQuery, array($sExtractorName));
$aTempRes = DBUtil::getResultArray($aQuery);
$aRes = array();
for ($i = 0; $i < count($aTempRes); $i++) {
if (!in_array($aTempRes[$i]['mimetypes'], $aRes)) {
$aRes[] = $aTempRes[$i]['mimetypes'];
}
}
return $aRes;
}
示例6: display_viewlet
function display_viewlet()
{
$oKTTemplating =& KTTemplating::getSingleton();
$oTemplate =& $oKTTemplating->loadTemplate("ktcore/document/viewlets/workflow");
if (is_null($oTemplate)) {
return "";
}
$oWorkflowState = KTWorkflowState::get($this->oDocument->getWorkflowStateId());
if (PEAR::isError($oWorkflowState)) {
return "";
}
$aDisplayTransitions = array();
$aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($this->oDocument, $this->oUser);
if (empty($aTransitions)) {
return "";
}
// Check if the document has been checked out
$bIsCheckedOut = $this->oDocument->getIsCheckedOut();
$iId = $this->oDocument->getId();
if ($bIsCheckedOut) {
// If document is checked out, don't link into the workflow.
$aDisplayTransitions = array();
} else {
foreach ($aTransitions as $oTransition) {
if (is_null($oTransition) || PEAR::isError($oTransition)) {
continue;
}
$aDisplayTransitions[] = array('url' => KTUtil::ktLink('action.php', 'ktcore.actions.document.workflow', array("fDocumentId" => $iId, "action" => "quicktransition", "fTransitionId" => $oTransition->getId())), 'name' => $oTransition->getName());
}
}
//Retreive the comment for the previous transition
$aCommentQuery = array("SELECT comment FROM document_transactions\n where transaction_namespace='ktcore.transactions.workflow_state_transition'\n AND document_id = ?\n ORDER BY id DESC LIMIT 1;");
$aCommentQuery[] = array($iId);
$aTransitionComments = DBUtil::getResultArray($aCommentQuery);
$oLatestTransitionComment = null;
if (!empty($aTransitionComments)) {
$aRow = $aTransitionComments[0];
$oLatestTransitionComment = $aRow['comment'];
$iCommentPosition = strpos($oLatestTransitionComment, ':');
//comment found after first colon in string
if ($iCommentPosition > 0) {
$oLatestTransitionComment = substr($oLatestTransitionComment, $iCommentPosition + 2, strlen($oLatestTransitionComment) - $iCommentPosition);
} else {
$oLatestTransitionComment = null;
}
}
$oTemplate->setData(array('context' => $this, 'bIsCheckedOut' => $bIsCheckedOut, 'transitions' => $aDisplayTransitions, 'state_name' => $oWorkflowState->getName(), 'comment' => $oLatestTransitionComment));
return $oTemplate->render();
}
示例7: getNewDashlets
/**
* Get any dashlets added since the user's last login
*
* @param object $oUser
*/
function getNewDashlets($oUser, $sCurrent)
{
$new = array();
$inactive = array();
static $sInactive = '';
$sIgnore = !empty($sInactive) ? $sCurrent . ',' . $sInactive : $sCurrent;
// Get all dashlets that haven't already been displayed to the user and are active for the user
$query = "SELECT h.classname, h.pathname, h.plugin FROM plugin_helper h\n INNER JOIN plugins p ON (h.plugin = p.namespace)\n WHERE p.disabled = 0 AND classtype = 'dashlet' ";
if (!empty($sIgnore)) {
$query .= " AND h.classname NOT IN ({$sIgnore})";
}
$res = DBUtil::getResultArray($query);
// If the query is not empty, get the dashlets and return the new active ones
// Add the inactive ones the list.
if (!PEAR::isError($res) && !empty($res)) {
$oRegistry =& KTPluginRegistry::getSingleton();
foreach ($res as $item) {
$name = $item['classname'];
$filename = $item['pathname'];
$sPluginName = $item['plugin'];
require_once $filename;
$oPlugin =& $oRegistry->getPlugin($sPluginName);
$oDashlet = new $name();
$oDashlet->setPlugin($oPlugin);
if ($oDashlet->is_active($oUser)) {
$new[] = $name;
} else {
$inactive[] = "'{$name}'";
}
}
// Add new inactive dashlets
$sNewInactive = implode(',', $inactive);
$sInactive = !empty($sInactive) ? $sInactive . ',' . $sNewInactive : $sNewInactive;
return $new;
}
return '';
}
示例8: getNextValuesForBehaviour
/**
* Given a behaviour, return an array of lookup ids (Metadata->id)
* that are available for each of the columns/fields that this
* behaviour's column affects.
*
* Return value:
*
* Associative array keyed by field_id, value is an array of lookup
* ids.
*
* array(
* 1 => array(1, 2, 3, 4),
* ...
* );
*/
function getNextValuesForBehaviour($oBehaviour)
{
$oBehaviour =& KTUtil::getObject('KTFieldBehaviour', $oBehaviour);
$aValues = array();
$sTable = KTUtil::getTableName('field_behaviour_options');
$aChildFieldIds = KTMetadataUtil::getChildFieldIds($oBehaviour->getFieldId());
foreach ($aChildFieldIds as $iFieldId) {
$aValues[$iFieldId] = array();
}
$aQuery = array("SELECT field_id, instance_id FROM {$sTable} WHERE behaviour_id = ?", array($oBehaviour->getId()));
$aRows = DBUtil::getResultArray($aQuery);
if (PEAR::isError($aRows)) {
return $aRows;
}
foreach ($aRows as $aRow) {
$oInstance =& KTValueInstance::get($aRow['instance_id']);
// need to wean out the disabled values.
// now get the metadata value.
$oMetadata = MetaData::get($oInstance->getFieldValueId());
if (PEAR::isError($oMetadata)) {
continue;
// invalid link. bugger.
}
if ($oMetadata->getDisabled()) {
continue;
// disabled.
}
$aValues[$aRow['field_id']][] = $oInstance->getFieldValueId();
}
return $aValues;
}
示例9: exec_db_query
/**
* Executes a database query
*
* @access private
* @global object $default Default config settings
* @param string $op The operation to perform
* @param array $group
* @return array $results
*/
private function exec_db_query($op, $group)
{
if (empty($group)) {
return array();
}
$exprbuilder = new SQLQueryBuilder($this->getContext());
$exprbuilder->setIncludeStatus($this->incl_status);
if (count($group) == 1) {
$sql = $exprbuilder->buildComplexQuery($group[0]);
} else {
$sql = $exprbuilder->buildSimpleQuery($op, $group);
}
if (empty($sql)) {
return array();
}
$results = array();
global $default;
$default->log->debug("SEARCH SQL: {$sql}");
$rs = DBUtil::getResultArray($sql);
if (PEAR::isError($rs)) {
throw new Exception($rs->getMessage());
}
if (count($group) == 1) {
//$default->log->debug("CASE 1");
$oCriteria = $this->checkComplexQuery($group[0]);
} else {
//$default->log->debug("CASE 2");
foreach ($group as $expr) {
$left = $expr->left();
$right = $expr->right();
$default->log->debug("FIELD-IS: " . $left->isOpExpr());
$fieldname = $left->getField();
$value = addslashes($right->getValue());
$rsField = DBUtil::getResultArray("SELECT * FROM document_fields WHERE name = \"{$fieldname}\";");
if ($rsField[0]['data_type'] == 'LARGE TEXT') {
$iCriteria = array();
$iCriteria[0] = array();
$iCriteria[0]['field'] = $fieldname;
$iCriteria[0]['value'] = $value;
$iCriteria[0]['not'] = $expr->not();
$oCriteria[] = $iCriteria[0];
/*$not = $expr->not()?' NOT ':'';
if (strpos($value, ' ') !== false)
$default->log->debug("CRITERION: $not$fieldname:\"$value\"");
else
$default->log->debug("CRITERION: $not$fieldname:$value");*/
}
//$default->log->debug("FIELD-TYPE: " . $oCriteria[0]['field']);
}
}
//$default->log->debug("TOTAL CRITERIA: " . count($oCriteria));
foreach ($rs as $item) {
$id = $item['id'];
$rank = $exprbuilder->getRanking($item);
if (!array_key_exists($id, $results) || $rank > $results[$id]->Rank) {
if ($this->context == ExprContext::DOCUMENT) {
if (count($oCriteria) > 0 && $this->checkValues($id, $oCriteria) || count($oCriteria) == 0) {
$results[$id] = new DocumentResultItem($id, $rank, $item['title'], $exprbuilder->getResultText($item), null, $this->incl_status);
}
} else {
$results[$id] = new FolderResultItem($id, $rank, $item['title'], $exprbuilder->getResultText($item));
}
}
}
return $results;
}
示例10: getFolderTransactions
function getFolderTransactions($aFolderIds)
{
$sFolderIds = implode(', ', $aFolderIds);
$sQuery = "SELECT FT.datetime AS datetime, 'Folder' AS type, F.name, F.full_path AS fullpath,\n \t DTT.name AS transaction_name, U.name AS user_name, FT.comment AS comment\n \t FROM folder_transactions AS FT LEFT JOIN users AS U ON FT.user_id = U.id\n \t LEFT JOIN document_transaction_types_lookup AS DTT ON DTT.namespace = FT.transaction_namespace\n \t LEFT JOIN folders AS F ON FT.folder_id = F.id\n \t WHERE FT.folder_id IN ({$sFolderIds})\n \t ORDER BY FT.datetime DESC\n \t LIMIT 4";
$aFolderTransactions = DBUtil::getResultArray($sQuery);
return $aFolderTransactions;
}
示例11: migrateDocuments
public function migrateDocuments($max = null)
{
global $default;
$default->log->info(_kt('migrateDocuments: starting'));
if (!$this->doesDiagnosticsPass(true)) {
$default->log->info(_kt('migrateDocuments: stopping - diagnostics problem. The dashboard will provide more information.'));
return;
}
if (KTUtil::getSystemSetting('migrationComplete') == 'true') {
$default->log->info(_kt('migrateDocuments: stopping - migration is complete.'));
return;
}
$config =& KTConfig::getSingleton();
if (is_null($max)) {
$max = $config->get('indexer/batchMigrateDocument', 500);
}
$lockFile = $config->get('cache/cacheDirectory') . '/migration.lock';
if (is_file($lockFile)) {
$default->log->info(_kt('migrateDocuments: stopping - migration lockfile detected.'));
return;
}
touch($lockFile);
$startTime = KTUtil::getSystemSetting('migrationStarted');
if (is_null($startTime)) {
KTUtil::setSystemSetting('migrationStarted', time());
}
$maxLoops = 5;
$max = ceil($max / $maxLoops);
$start = KTUtil::getBenchmarkTime();
$noDocs = false;
$numDocs = 0;
for ($loop = 0; $loop < $maxLoops; $loop++) {
$sql = "SELECT\n \t\t\tdocument_id, document_text\n\t\t\t\tFROM\n\t\t\t\t\tdocument_text\n\t\t\t\tORDER BY document_id\n \t\t\t\t\tLIMIT {$max}";
$result = DBUtil::getResultArray($sql);
if (PEAR::isError($result)) {
$default->log->info(_kt('migrateDocuments: db error'));
break;
}
$docs = count($result);
if ($docs == 0) {
$noDocs = true;
break;
}
$numDocs += $docs;
foreach ($result as $docinfo) {
$docId = $docinfo['document_id'];
$document = Document::get($docId);
if (PEAR::isError($document) || is_null($document)) {
$sql = "DELETE FROM document_text WHERE document_id={$docId}";
DBUtil::runQuery($sql);
$default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!'), $docId));
continue;
}
$version = $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber();
$targetFile = tempnam($tempPath, 'ktindexer');
if (file_put_contents($targetFile, $docinfo['document_text']) === false) {
$default->log->error(sprintf(_kt('migrateDocuments: Cannot write to \'%s\' for document id %d'), $targetFile, $docId));
continue;
}
// free memory asap ;)
unset($docinfo['document_text']);
$title = $document->getName();
$indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title, $version);
if ($indexStatus) {
$sql = "DELETE FROM document_text WHERE document_id={$docId}";
DBUtil::runQuery($sql);
} else {
$default->log->error(sprintf(_kt("migrateDocuments: Problem indexing document %d"), $docId));
}
@unlink($targetFile);
}
}
@unlink($lockFile);
$time = KTUtil::getBenchmarkTime() - $start;
KTUtil::setSystemSetting('migrationTime', KTUtil::getSystemSetting('migrationTime', 0) + $time);
KTUtil::setSystemSetting('migratedDocuments', KTUtil::getSystemSetting('migratedDocuments', 0) + $numDocs);
$default->log->info(sprintf(_kt('migrateDocuments: stopping - done in %d seconds!'), $time));
if ($noDocs) {
$default->log->info(_kt('migrateDocuments: Completed!'));
KTUtil::setSystemSetting('migrationComplete', 'true');
schedulerUtil::deleteByName('Index Migration');
$default->log->debug(_kt('migrateDocuments: Disabling \'Index Migration\' task by removing scheduler entry.'));
}
}
示例12: checkNewInstall
/**
* Check if this is a new installation
*
*/
function checkNewInstall()
{
// The date and time of installation is not stored anywhere so we work around it
// On installation the run_time of all tasks is set to '2007-10-01', so we check if all the tasks have the same run_time date with time set to 00:00:00
// We then set run_time to the current date, ensuring the time is not 00.
$query = 'SELECT count(*) as cnt, run_time FROM scheduler_tasks s GROUP BY run_time';
$res = DBUtil::getResultArray($query);
if (PEAR::isError($res)) {
return false;
}
// if they aren't all the same return false - not a fresh install
$iCnt = count($res);
if ($iCnt > 1) {
return false;
}
// Check if the time is 00
$sRunTime = $res[0]['run_time'];
$aRunTime = explode(' ', $sRunTime);
if (!isset($aRunTime[1]) || empty($aRunTime[1])) {
// set install date
schedulerUtil::setInstallDate();
return true;
}
if ($aRunTime[1] == '00:00:00') {
// set install date
schedulerUtil::setInstallDate();
return true;
}
return false;
}
示例13: registerMetdataFields
/**
* Registers metdata fields in system.
*
*/
private function registerMetdataFields()
{
$sql = "SELECT\n\t\t\t\t\tfs.name as fieldset, f.name as field, fs.id as fsid, f.id as fid, f.data_type\n\t\t\t\tFROM\n\t\t\t\t\tfieldsets fs\n\t\t\t\t\tINNER JOIN document_fields f ON f.parent_fieldset=fs.id\n\t\t\t\tWHERE\n\t\t\t\t\tfs.disabled=0";
$result = DBUtil::getResultArray($sql);
foreach ($result as $record) {
$fieldset = addslashes($record['fieldset']);
$field = addslashes($record['field']);
$fieldsetid = $record['fsid'];
$fieldid = $record['fid'];
$type = $record['data_type'];
$classname = "MetadataField{$fieldid}";
$classdefn = "\n\t\t\t\tclass {$classname} extends MetadataField\n\t\t\t\t{\n\t\t\t\t\tpublic function __construct()\n\t\t\t\t\t{\n\t\t\t\t\t\tparent::__construct('{$fieldset}','{$field}',{$fieldsetid}, {$fieldid});" . ($type == 'INT' ? '$this->isValueQuoted(false);' : '') . "\n\t\t\t\t\t}\n\t\t\t\t}";
eval($classdefn);
$field = new $classname();
$this->registerField($field);
}
}
示例14: affectedTypes
/**
* Method to get the list of affected filetypes when an extractor is not available
* @param string $extractor Name of the Extractor
* @return string List of Affected filetypes
*/
public function affectedTypes($extractor)
{
// Create SQL
$sql = "SELECT filetypes FROM mime_types INNER JOIN mime_extractors ON (extractor_id = mime_extractors.id)\n WHERE mime_extractors.name = ?";
// Create Query
$aQuery = array($sql, array($extractor));
// Get Results from DB
$aTempRes = DBUtil::getResultArray($aQuery);
$str = '';
// Prepare into a string
if (count($aTempRes) > 0) {
$comma = '';
foreach ($aTempRes as $mime) {
$str .= $comma . $mime['filetypes'];
$comma = ', ';
}
}
return $str;
}
示例15: loadProcessors
private function loadProcessors()
{
// Get list of registered processors (plugins)
$query = 'SELECT h.* FROM plugin_helper h
INNER JOIN plugins p ON (p.namespace = h.plugin)
WHERE p.disabled = 0 AND h.classtype = "processor"';
$results = DBUtil::getResultArray($query);
if (PEAR::isError($results)) {
global $default;
$default->log->debug('documentProcessor: error loading processors') . ' - ' . $results->getMessage();
return false;
}
if (empty($results)) {
return false;
}
$processors = array();
foreach ($results as $item) {
$path = KTUtil::isAbsolutePath($item['pathname']) ? $item['pathname'] : KT_DIR . DIRECTORY_SEPARATOR . $item['pathname'];
require_once $path;
$processors[] = new $item['classname']();
}
usort($processors, 'orderProcessors');
return $processors;
}