当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtil::getOneResultKey方法代码示例

本文整理汇总了PHP中DBUtil::getOneResultKey方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::getOneResultKey方法的具体用法?PHP DBUtil::getOneResultKey怎么用?PHP DBUtil::getOneResultKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


在下文中一共展示了DBUtil::getOneResultKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHandler

 function getHandler()
 {
     $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection');
     $sQuery .= ' WHERE event_ns = ?';
     $aParams = array('ktstandard.workflowassociation.handler');
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns');
     return $res;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:8,代码来源:adminpage.php

示例2: is_active

 function is_active($oUser)
 {
     if (!Permission::userIsSystemAdministrator($oUser)) {
         return false;
     }
     $sql = "select count(*) as no from document_text";
     $no = DBUtil::getOneResultKey($sql, 'no');
     if ($no == 0) {
         return false;
     }
     $this->migratingDocuments = $no;
     return true;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:13,代码来源:MigrationDashlet.php

示例3: outputHelpImage

 function outputHelpImage($sSubPath)
 {
     // FIXME there are error cases here ...
     $aPathInfo = KTHelp::_getLocationInfo($sSubPath);
     if (PEAR::isError($aPathInfo)) {
         return $aPathInfo;
     }
     // gets caught further up the stack
     $pi = pathinfo($aPathInfo['external']);
     $mime_type = "";
     $sExtension = KTUtil::arrayGet($pi, 'extension');
     if (!empty($sExtension)) {
         $mime_type = DBUtil::getOneResultKey(array("SELECT mimetypes FROM " . KTUtil::getTableName('mimetypes') . " WHERE LOWER(filetypes) = ?", $sExtension), "mimetypes");
     }
     header("Content-Type: {$mime_type}");
     header("Content-Length: " . filesize($fspath));
     readfile($fspath);
     // does this output it?!
     exit(0);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:20,代码来源:help.inc.php

示例4: KTWorkflowAssociationDelegator

 function KTWorkflowAssociationDelegator()
 {
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('workflow', 'objectModification');
     // if we have _some_ triggers.
     if (!empty($aTriggers)) {
         $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection');
         $sQuery .= ' WHERE event_ns = ?';
         $aParams = array('ktstandard.workflowassociation.handler');
         $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns');
         if (PEAR::isError($res)) {
             $this->_handler = new KTWorkflowAssociationHandler();
         }
         if (array_key_exists($res, $aTriggers)) {
             $this->_handler = new $aTriggers[$res][0]();
         } else {
             $this->_handler = new KTWorkflowAssociationHandler();
         }
     } else {
         $this->_handler = new KTWorkflowAssociationHandler();
     }
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:22,代码来源:KTWorkflowAssociation.php

示例5: getMimeTypeID

 /**
  * Get the mime type primary key for a specific mime type
  *
  * @param string detected mime type
  * @param string filename
  * @return int mime type primary key if found, else default mime type primary key (text/plain)
  */
 function getMimeTypeID($sMimeType, $sFileName, $sTempFile = null)
 {
     global $default;
     $sTable = KTUtil::getTableName('mimetypes');
     // check by file extension
     $sExtension = KTMime::stripAllButExtension($sFileName);
     $res = DBUtil::getOneResultKey(array("SELECT id FROM " . $sTable . " WHERE LOWER(filetypes) = ?", array($sExtension)), 'id');
     if (PEAR::isError($res) || empty($res)) {
         // pass ?!
     } else {
         return $res;
     }
     // get the mime type id
     if (isset($sMimeType)) {
         $res = DBUtil::getResultArray(array("SELECT id FROM " . $sTable . " WHERE mimetypes = ?", array($sMimeType)));
         if (PEAR::isError($res)) {
             // pass ?!
         }
         if (count($res) != 0) {
             return $res[0]['id'];
         }
     }
     if (!is_null($sTempFile)) {
         // The default is a binary file, so if mime magic can resolve better, lets try...
         $sMimeType = KTMime::getMimeTypeFromFile($sTempFile);
         if (!empty($sMimeType)) {
             $res = DBUtil::getResultArray(array("SELECT id FROM " . $sTable . " WHERE mimetypes = ?", array($sMimeType)));
             if (PEAR::isError($res)) {
                 // pass ?!
             }
             if (count($res) != 0) {
                 return $res[0]['id'];
             }
         }
     }
     //otherwise return the default mime type
     return KTMime::getDefaultMimeTypeID();
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:45,代码来源:mime.inc.php

示例6: _getFieldIdForMetadataId

 function _getFieldIdForMetadataId($iMetadata)
 {
     $sTable = 'metadata_lookup';
     $sQuery = "SELECT document_field_id FROM " . $sTable . " WHERE id = ?";
     $aParams = array($iMetadata);
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'document_field_id');
     if (PEAR::isError($res)) {
         return false;
     }
     return $res;
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:11,代码来源:KTWidgets.php

示例7: findRootObjectForPermissionObject

 /**
  * Given a specific permission object, find the object (Folder or
  * Document) that is the root of that permission object - the one
  * object that has this permission object, but its parent has a
  * different one.
  */
 function findRootObjectForPermissionObject($oPO)
 {
     global $default;
     /*
      * If there are any folders with the permission object, then it
      * is set by _a_ folder.  All folders found will have a common
      * ancestor folder, which will be the one with:
      *
      * Potential hack: The shortest parent_folder_ids
      *
      * Potential non-hack: Choose random folder, check parent for
      * permission object recurringly until it changes.  Last success
      * is the ancestor parent...
      */
     $sQuery = "SELECT id FROM {$default->folders_table} WHERE permission_object_id = ? ORDER BY LENGTH(parent_folder_ids) LIMIT 1";
     $aParams = array($oPO->getID());
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
     if (!is_null($res)) {
         return Folder::get($res);
     }
     $sQuery = "SELECT id FROM {$default->documents_table} WHERE permission_object_id = ? LIMIT 1";
     $aParams = array($oPO->getID());
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
     if (!is_null($res)) {
         return Document::get($res);
     }
     return false;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:34,代码来源:permissionutil.inc.php

示例8: _folderOrDocument

 function _folderOrDocument($sPath)
 {
     global $default;
     $sFileName = basename($sPath);
     $sFolderPath = dirname($sPath);
     $aFolderNames = split('/', $sFolderPath);
     $iFolderID = 0;
     $aRemaining = $aFolderNames;
     while (count($aRemaining)) {
         $sFolderName = $aRemaining[0];
         $aRemaining = array_slice($aRemaining, 1);
         if ($sFolderName === '') {
             continue;
         }
         $sQuery = 'SELECT id FROM folders WHERE parent_id = ? AND name = ?';
         $aParams = array($iFolderID, $sFolderName);
         $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
         if (PEAR::isError($id)) {
             // XXX: log error
             return false;
         }
         if (is_null($id)) {
             // Some intermediary folder path doesn't exist
             return false;
         }
         $default->log->error('iFolderID set to ' . print_r($id, true));
         $iFolderID = (int) $id;
     }
     $sQuery = sprintf('SELECT d.id FROM %s AS d' . ' LEFT JOIN %s AS dm ON (d.metadata_version_id = dm.id) LEFT JOIN %s AS dc ON (dm.content_version_id = dc.id)' . ' WHERE d.folder_id = ? AND dc.filename = ?', KTUtil::getTableName(documents), KTUtil::getTableName('document_metadata_version'), KTUtil::getTableName('document_content_version'));
     $aParams = array($iFolderID, $sFileName);
     $iDocumentID = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
     if (PEAR::isError($iDocumentID)) {
         // XXX: log error
         return false;
     }
     if ($iDocumentID === null) {
         $sQuery = 'SELECT id FROM folders WHERE parent_id = ? AND name = ?';
         $aParams = array($iFolderID, $sFileName);
         $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
         if (PEAR::isError($id)) {
             // XXX: log error
             return false;
         }
         if (is_null($id)) {
             if ($sFileName === '') {
                 return array($iFolderID, null);
             }
             // XXX: log error
             return array($iFolderID, false);
         }
         return array($id, null);
     }
     return array($iFolderID, (int) $iDocumentID);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:54,代码来源:browseutil.inc.php

示例9: tagFieldsetExists

 /**
  * function to check if the fieldset exists in the database
  *
  * @return boolean
  */
 function tagFieldsetExists()
 {
     $sQuery = 'SELECT fs.id AS id FROM fieldsets AS fs ' . 'WHERE namespace = \'tagcloud\'';
     $iFieldset = DBUtil::getOneResultKey(array($sQuery), 'id');
     if (PEAR::isError($iFieldset)) {
         global $default;
         $default->log->error('Tag Cloud plugin - error checking tag fieldset: ' . $iFieldset->getMessage());
         return $iFieldset;
     }
     if (is_numeric($iFieldset)) {
         return $iFieldset;
     } else {
         return false;
     }
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:20,代码来源:TagCloudPlugin.php

示例10: createFolderDetailsPermission

 function createFolderDetailsPermission()
 {
     $sPermissionsTable = KTUtil::getTableName('permissions');
     $bExists = DBUtil::getOneResultKey("SELECT COUNT(id) AS cnt FROM {$sPermissionsTable} WHERE name = 'ktcore.permissions.folder_details'", 'cnt');
     if ($bExists) {
         return;
     }
     DBUtil::startTransaction();
     $aPermissionInfo = array('human_name' => 'Core: Folder Details', 'name' => 'ktcore.permissions.folder_details', 'built_in' => true);
     $res = DBUtil::autoInsert($sPermissionsTable, $aPermissionInfo);
     if (PEAR::isError($res)) {
         return $res;
     }
     $iFolderDetailsPermissionId = $res;
     $sQuery = "SELECT id FROM {$sPermissionsTable} WHERE name = ?";
     $aParams = array("ktcore.permissions.read");
     $iReadPermissionId = DBUtil::getOneResultKey(array($sQuery, $aParams), "id");
     $sPermissionAssignmentsTable = KTUtil::getTableName('permission_assignments');
     $sQuery = "SELECT permission_object_id, permission_descriptor_id FROM {$sPermissionAssignmentsTable} WHERE permission_id = ?";
     $aParams = array($iReadPermissionId);
     $aRows = DBUtil::getResultArray(array($sQuery, $aParams));
     foreach ($aRows as $aRow) {
         $aRow['permission_id'] = $iFolderDetailsPermissionId;
         DBUtil::autoInsert($sPermissionAssignmentsTable, $aRow);
     }
     $sDocumentTable = KTUtil::getTableName('documents');
     $sFolderTable = KTUtil::getTableName('folders');
     DBUtil::runQuery("UPDATE {$sDocumentTable} SET permission_lookup_id = NULL");
     DBUtil::runQuery("UPDATE {$sFolderTable} SET permission_lookup_id = NULL");
     DBUtil::commit();
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:UpgradeFunctions.inc.php

示例11: capture_zseqs

 /**
  * Make a zseq report
  *
  * @param string $tables
  * @param string $filename
  */
 private function capture_zseqs($tables, $filename)
 {
     $zseqs = '<h1>Table Counter Report</h1>';
     $zseqs .= '<table border=1 cellpadding=0 cellspacing=0>';
     $zseqs .= '<tr><td>Table<td>Max ID<td>ZSEQ<td>Status';
     foreach ($tables as $ztablename) {
         if (substr($ztablename, 0, 5) != 'zseq_') {
             continue;
         }
         $tablename = substr($ztablename, 5);
         $sql = "SELECT max(id) as maxid FROM {$tablename}";
         $maxid = DBUtil::getOneResultKey($sql, 'maxid');
         $sql = "SELECT id FROM {$ztablename}";
         $zseqid = DBUtil::getOneResultKey($sql, 'id');
         $note = is_null($maxid) || $maxid <= $zseqid ? 'OK' : 'FAIL';
         if ($note == 'FAIL' && $maxid > $zseqid) {
             $note = 'COUNTER PROBLEM! maxid should be less than or equal to zseq';
         }
         if (PEAR::isError($maxid)) {
             $maxid = '??';
             $note = "STRANGE - DB ERROR ON {$tablename}";
         }
         if (PEAR::isError($zseqid)) {
             $zseqid = '??';
             $note = "STRANGE - DB ERROR ON {$ztablename}";
         }
         if (is_null($maxid)) {
             $maxid = 'empty';
         }
         if (is_null($zseqid)) {
             $zseqid = 'empty';
             $note = "STRANGE - ZSEQ SHOULD NOT BE EMPTY ON {$ztablename}";
         }
         $zseqs .= "<tr><td>{$tablename}<td>{$maxid}<td>{$zseqid}<td>{$note}\r\n";
     }
     $zseqs .= "</table>";
     file_put_contents($filename, $zseqs);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:44,代码来源:support.inc.php

示例12: checkConditionalFieldsetCompleteness

 /**
  * Checks whether a conditional fieldset has the necessary
  * relationships set up to be usable - this means that for each
  * field, no matter how it is reached, there is at least one option
  * available to choose.
  */
 function checkConditionalFieldsetCompleteness($oFieldset)
 {
     $oFieldset =& KTUtil::getObject('KTFieldset', $oFieldset);
     if ($oFieldset->getIsConditional() == false) {
         // If we're not conditional, we are fine.
         return true;
     }
     /*
      * First, ensure at least one master field item has a behaviour
      * assigned to it.  That allows at least one item in the master
      * field to be chosen.
      */
     $iMasterFieldId = $oFieldset->getMasterFieldId();
     $sTable = KTUtil::getTableName('field_value_instances');
     $sLookupTable = KTUtil::getTableName('metadata_lookup');
     $aQuery = array("SELECT COUNT(FVI.id) AS cnt FROM {$sTable} AS FVI LEFT JOIN {$sLookupTable} AS ML ON (FVI.field_value_id = ML.id) WHERE FVI.field_id = ? AND ML.disabled = 0", array($iMasterFieldId));
     $iCount = DBUtil::getOneResultKey($aQuery, 'cnt');
     if (PEAR::isError($iCount)) {
         return $iCount;
     }
     $GLOBALS['default']->log->debug("Number of value instances for master field: {$iCount}");
     if ($iCount == 0) {
         $GLOBALS['default']->log->debug("Number of value instances for master field is zero, failing");
         return PEAR::raiseError(_kt("Master field has no values which are assigned to behaviours."));
     }
     $GLOBALS['default']->log->debug("Number of value instances for master field is positive, continuing");
     // fix for KTS-1023
     // check that each master-field value has a valueinstance assigned.
     $sTable = KTUtil::getTableName('metadata_lookup');
     $aQuery = array("SELECT COUNT(id) AS cnt FROM {$sTable} WHERE document_field_id = ? AND disabled = 0 ", array($iMasterFieldId));
     $iValCount = DBUtil::getOneResultKey($aQuery, 'cnt');
     // assumes that there cannot be more than 1 value instance for each master-field-value.
     if ($iValCount != $iCount) {
         return PEAR::raiseError(sprintf(_kt('%d values for the Master Field are not assigned to behaviours.'), $iValCount - $iCount));
     }
     /*
      * Plan: For each behaviour that is assigned on the system,
      * ensure that it allows at least one value instance in each of
      * the fields that it needs to affect.
      */
     $sTable = KTUtil::getTableName('field_value_instances');
     $sFieldTable = KTUtil::getTableName('document_fields');
     $aQuery = array("SELECT DISTINCT FV.behaviour_id AS behaviour_id FROM {$sTable} AS FV INNER JOIN {$sFieldTable} AS F ON FV.field_id = F.id WHERE F.parent_fieldset = ? AND FV.behaviour_id IS NOT NULL", array($oFieldset->getId()));
     $aBehaviourIds = DBUtil::getResultArrayKey($aQuery, 'behaviour_id');
     if (PEAR::isError($aBehaviourIds)) {
         return $aBehaviourIds;
     }
     foreach ($aBehaviourIds as $iBehaviourId) {
         $GLOBALS['default']->log->debug("Checking behaviour id: " . $iBehaviourId);
         $oBehaviour =& KTFieldBehaviour::get($iBehaviourId);
         $sBehaviourName = $oBehaviour->getName();
         $sBehaviourHumanName = $oBehaviour->getHumanName();
         $iParentFieldId = $oBehaviour->getFieldId();
         $GLOBALS['default']->log->debug("   field is " . $iParentFieldId);
         $aNextFields = KTMetadataUtil::getChildFieldIds($iParentFieldId);
         $oParentField =& DocumentField::get($iParentFieldId);
         $sParentFieldName = $oParentField->getName();
         $GLOBALS['default']->log->debug("   next fields must include " . print_r($aNextFields, true));
         $sTable = KTUtil::getTableName('field_behaviour_options');
         $aQuery = array("SELECT DISTINCT field_id FROM {$sTable} WHERE behaviour_id = ?", array($iBehaviourId));
         $aFields = DBUtil::getResultArrayKey($aQuery, 'field_id');
         $GLOBALS['default']->log->debug("   actual fields are " . print_r($aNextFields, true));
         /*
         foreach ($aNextFields as $iFieldId) {
             if (!in_array($iFieldId, $aFields)) {
                 $GLOBALS['default']->log->debug("   field $iFieldId is not included, failing");
                 $oChildField =& DocumentField::get($iFieldId);
                 $sChildFieldName = $oChildField->getName();
                 return PEAR::raiseError("Child field $sChildFieldName of parent field $sParentFieldName has no selectable values in behaviour $sBehaviourHumanName ($sBehaviourName)");
         
         }
         */
     }
     $GLOBALS['default']->log->debug("Got through: passed!");
     return true;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:82,代码来源:metadatautil.inc.php

示例13: getByName

 /**
  * Using the name, the role can be resolved.
  *
  * @author KnowledgeTree Team
  * @access public
  * @static
  * @param string $name
  * @return KTAPI_Role Returns null if  there is no match.
  */
 public static function getByName($name)
 {
     $sql = 'SELECT id FROM roles WHERE name=?';
     $id = DBUtil::getOneResultKey(array($sql, array($name)), 'id');
     if (PEAR::isError($id)) {
         return $id;
     }
     $role = Role::get($id);
     return new KTAPI_Role($role);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:19,代码来源:KTAPIAcl.inc.php

示例14: readResource

 function readResource($sPath)
 {
     global $default;
     $php_file = ".php";
     if (substr($sPath, -strlen($php_file)) === $php_file) {
         require_once $php_file;
     } else {
         $pi = pathinfo($sPath);
         $mime_type = "";
         $sExtension = KTUtil::arrayGet($pi, 'extension');
         if (!empty($sExtension)) {
             $mime_type = DBUtil::getOneResultKey(array("SELECT mimetypes FROM " . $default->mimetypes_table . " WHERE LOWER(filetypes) = ?", $sExtension), "mimetypes");
         }
         if (empty($mime_type)) {
             $mime_type = "application/octet-stream";
         }
         $sFullPath = KT_DIR . '/plugins' . $sPath;
         header("Content-Type: {$mime_type}");
         header("Content-Length: " . filesize($sFullPath));
         readfile($sFullPath);
     }
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:22,代码来源:pluginutil.inc.php

示例15: renderData

 function renderData($aDataRow)
 {
     $iDocumentId =& $aDataRow['document']->getId();
     $aLocs = array();
     $bFound = true;
     $iLastFound = 0;
     $iNumFound = 0;
     while ($bFound && $iNumFound < 5) {
         $sQuery = "SELECT LOCATE(?, document_text, ?) AS posi FROM document_searchable_text WHERE document_id = ?";
         $aParams = array($this->sSearch, $iLastFound + 1, $iDocumentId);
         $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'posi');
         if (PEAR::isError($res)) {
             var_dump($res);
             exit(0);
         }
         if (empty($res)) {
             break;
         }
         $iNumFound++;
         $iLastFound = $res;
         $bFound = $res;
         if ($iLastFound) {
             $aLocs[] = $iLastFound;
         }
     }
     $iBack = 20;
     $iForward = 50;
     $aTexts = array();
     foreach ($aLocs as $iLoc) {
         $iThisForward = $iForward;
         $iThisBack = $iBack;
         if ($iLoc - $iBack < 0) {
             $iThisForward = $iForward + $iLoc;
             $iThisBack = 0;
             $iLoc = 1;
         }
         $sQuery = "SELECT SUBSTRING(document_text FROM ? FOR ?) AS text FROM document_searchable_text WHERE document_id = ?";
         $aParams = array($iLoc - $iThisBack, $iThisForward + $iThisBack, $iDocumentId);
         $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'text');
         if (PEAR::isError($res)) {
             var_dump($res);
             exit(0);
         }
         $res = htmlentities($res);
         $aSearch = array(sprintf('#(%s)#i', $this->sSearch));
         $aReplace = array('&nbsp; <span class="searchresult" style="color: red">\\1</span> &nbsp;');
         $sText = preg_replace($aSearch, $aReplace, $res);
         $aFirstSpace = array(strpos($sText, " "), strpos($sText, "\n"));
         $iFirstSpace = false;
         foreach ($aFirstSpace as $iPos) {
             if ($iFirstSpace === false) {
                 $iFirstSpace = $iPos;
                 continue;
             }
             if ($iPos === false) {
                 continue;
             }
             if ($iPos < $iFirstSpace) {
                 $iFirstSpace = $iPos;
             }
         }
         if ($iFirstSpace === false) {
             $iFirstSpace = -1;
         }
         $iLastSpace = strrpos($sText, " ");
         $sText = substr($sText, $iFirstSpace + 1, $iLastSpace - $iFirstSpace - 1);
         $sText = str_replace("&nbsp; ", "", $sText);
         $sText = str_replace(" &nbsp;", "", $sText);
         $aTexts[] = $sText;
     }
     $sFullTexts = join(" &hellip; ", $aTexts);
     return sprintf('<div>%s</div><div class="searchresults" style="margin-top: 0.5em; color: grey">%s</div>', parent::renderData($aDataRow), $sFullTexts);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:73,代码来源:simpleSearch.php


注:本文中的DBUtil::getOneResultKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。