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


PHP ApiBase::readConstraints方法代码示例

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


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

示例1: search

 function search()
 {
     # Database info (including username+pass) in external file
     if (file_exists('/home/andre/config.php')) {
         require_once '/home/andre/config.php';
     } elseif (file_exists('config.php')) {
         require_once 'config.php';
     } else {
         die('Couldn\'t find config file ');
     }
     include 'Format.php';
     #formats the output
     include 'ApiBase.php';
     #functions used by multiple modules
     include 'ApiGet.php';
     #standard sql query stuff
     include 'ApiStats.php';
     #stats about the database
     include 'ApiAdmin.php';
     #various functions that the average user wouldn't care about
     include 'ApiArtist.php';
     #hook into the artist_table
     #include('ApiHelp.php');     #help file/documentation
     global $helpurl;
     /*
      * Trying to connect to mysql server and database
      * Output Temporary error if unable to.
      */
     if (!@mysql_connect($dbServer, $dbUser, $dbPassword)) {
         $results = ApiBase::makeErrorResult('500', 'Temporary Error. ' . 'Our server might be down, please try again later.[' . mysql_error() . ']', null);
         $errors = 1;
     }
     if (!@mysql_select_db($dbDatabase)) {
         $results = ApiBase::makeErrorResult('500', 'Temporary Error. ' . 'Our server might be down, please try again later.[' . mysql_error() . ']', null);
         $errors = 1;
     }
     /*
      * Set up jsonp compatibility
      */
     if (strtolower($_GET['format']) == 'jsonp') {
         if (!isset($_GET['callback'])) {
             $results = ApiBase::makeErrorResult('640', 'JSONP Error. ' . 'Cannot request JSONP without a callback', null);
             $errors = 1;
         }
     }
     /*
      * If no errors were found during connection
      * let's proceed with our queries
      */
     if (!$errors) {
         mysql_query("SET CHARACTER SET utf8");
         #deal with general constraints
         try {
             $constraints = ApiBase::readConstraints();
         } catch (ValueLimitException $e) {
             $results = ApiBase::makeErrorResult('602', $e->getMessage(), null);
             $errors = 1;
         } catch (CharacterLimitException $e) {
             $results = ApiBase::makeErrorResult('603', $e->getMessage(), null);
             $errors = 1;
         } catch (Exception $e) {
             $results = ApiBase::makeErrorResult('600', $e->getMessage(), null);
             $errors = 1;
         }
         #if kml/geojson output format then make sure has_coords is set
         if (($_GET['format'] == 'kml' or $_GET['format'] == 'geojson') and !isset($_GET['has_coords'])) {
             $constraints['coords'] = ApiBase::requireCoords();
         }
     }
     if (!$errors) {
         #switch by action; return results array
         switch (strtolower($_GET['action'])) {
             case 'get':
                 $results = ApiGet::run($constraints);
                 break;
             case 'artist':
                 $results = ApiArtist::run($constraints);
                 break;
             case 'statistics':
                 /*
                  * Outputs counts per table/muni/county/artist/withCoords/withPics
                  */
                 $results = ApiStats::run($constraints);
                 break;
             case 'admin':
                 /*
                  * should generate a file with changes (since a certain date) and/or
                  * list all entries (with changes) from a given source which has ugc=1.
                  * Possibly use this to create an rss feed?
                  */
                 $results = ApiAdmin::run($constraints);
                 break;
             case 'help':
                 header('Location: ' . $helpurl);
                 break;
             default:
                 $results = ApiBase::makeErrorResult('601', 'Action Failed. ' . 'Sorry but "' . $_GET['action'] . '" is not a valid action for this api.', $warning);
                 break;
         }
     }
//.........这里部分代码省略.........
开发者ID:Abbe98,项目名称:ODOK,代码行数:101,代码来源:ApiMain.php


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