示例#1
0
 public static function getSQLOptionsAsString($requestoptions, $valuecol = NULL)
 {
     $options = DBHelper::getSQLOptions($requestoptions, $valuecol);
     $limit = array_key_exists('LIMIT', $options) && is_numeric($options['LIMIT']) ? 'LIMIT ' . $options['LIMIT'] : '';
     $offset = array_key_exists('OFFSET', $options) && is_numeric($options['OFFSET']) ? 'OFFSET ' . $options['OFFSET'] : '';
     $orderby = array_key_exists('ORDER BY', $options) ? 'ORDER BY ' . $options['ORDER BY'] : '';
     return $orderby . ' ' . $limit . ' ' . $offset;
 }
 function getDirectSuperProperties(Title $attribute, $requestoptions = NULL)
 {
     $db =& wfGetDB(DB_SLAVE);
     $page = $db->tableName('page');
     $smw_subprops = $db->tableName('smw_subprops');
     $sql = 'subject_title = ' . $db->addQuotes($attribute->getDBkey()) . ' AND page_is_redirect = 0 AND object_title = page_title AND page_namespace = ' . SMW_NS_PROPERTY;
     $res = $db->select(array($smw_subprops, $page), 'object_title', $sql, 'SMW::getDirectSuperProperties', DBHelper::getSQLOptions($requestoptions, 'object_title'));
     $result = array();
     if ($db->numRows($res) > 0) {
         while ($row = $db->fetchObject($res)) {
             if (smwf_om_userCan($row->object_title, 'read', SMW_NS_PROPERTY) === "true") {
                 $result[] = Title::newFromText($row->object_title, SMW_NS_PROPERTY);
             }
         }
     }
     $db->freeResult($res);
     return $result;
 }