Exemplo n.º 1
0
 function run($constraints)
 {
     /*
      * use options to choose a query generating function
      * then
      */
     $table = isset($_GET['table']) ? strtolower($_GET['table']) : null;
     $column = isset($_GET['column']) ? strtolower($_GET['column']) : null;
     $split = isset($_GET['split']) ? strtolower($_GET['split']) : null;
     #choose function based on given parameters
     try {
         if (isset($table) and isset($column)) {
             $warning = 'You cannot specify both table and column; ignoring table parameter. ';
             list($response, $warning) = self::splitSelector($split, 'main', $column, $constraints, $warning);
         } elseif (isset($table)) {
             list($response, $warning) = self::splitSelector($split, $table, NULL, $constraints, $warning);
         } elseif (isset($column)) {
             list($response, $warning) = self::splitSelector($split, 'main', $column, $constraints, $warning);
         } elseif (isset($split)) {
             #only split is set
             $warning = 'No table specified for split; assuming table = "main". ';
             list($response, $warning) = self::splitSelector($split, 'main', NULL, $constraints, $warning);
         } else {
             $warning = 'Neither column, table nor split parameter defined; assuming table = "all". ';
             $response = self::countTable('all', $constraints);
         }
     } catch (Exception $e) {
         return ApiBase::makeErrorResult('620', 'Count Failed. ' . 'Probably wrong parameter name supplied. [' . $e->getMessage() . ']', $warning);
     }
     return ApiBase::makeSuccessResult($warning, $response);
 }