Пример #1
0
 /**
  * returns prepared url able to require sorting for each column
  * of the pager results
  *
  * @param  string $url
  * @return array
  */
 function get_sort_url_list($url, $context = null)
 {
     $urlList = array();
     $sortArgList = array();
     if (count($this->get_result_list())) {
         list($firstResultRow) = $this->get_result_list();
         $sortArgList = array_keys($firstResultRow);
     } else {
         $sortArgList = claro_sql_field_names($this->sql);
     }
     foreach ($sortArgList as $thisArg) {
         if (array_key_exists($thisArg, $this->sortKeyList) && $this->sortKeyList[$thisArg] != SORT_DESC) {
             $direction = SORT_DESC;
         } else {
             $direction = SORT_ASC;
         }
         $urlList[$thisArg] = $url . (strstr($url, '?') !== false ? '&' : '?') . $this->sortKeyParamName . '=' . urlencode($thisArg) . '&' . $this->sortDirParamName . '=' . $direction . claro_url_relay_context('&', $context);
     }
     return $urlList;
 }
Пример #2
0
/**
 * CLAROLINE SQL query and fetch array wrapper. It returns all the result in
 * associative array ARRANGED BY COLUMNS.
 *
 * @param  string  $sqlQuery  the sql query
 * @param  handler $dbHandler optional
 * @return associative array containing all the result arranged by columns
 *
 * @see    claro_sql_query()
 * @author Hugues Peeters <*****@*****.**>,
 * @deprecated since Claroline 1.9, use Claroline::getDatabase() and new classes
 *  in database/database.lib.php instead
 */
function claro_sql_query_fetch_all_cols($sqlQuery, $dbHandler = '#')
{
    $result = claro_sql_query($sqlQuery, $dbHandler);
    if ($result) {
        $colList = array();
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            foreach ($row as $key => $value) {
                $colList[$key][] = $value;
            }
        }
        if (count($colList) == 0) {
            // WHEN NO RESULT, THE SCRIPT CREATES AT LEAST COLUMN HEADERS
            $FieldNamelist = claro_sql_field_names($sqlQuery, $result);
            foreach ($FieldNamelist as $thisFieldName) {
                $colList[$thisFieldName] = array();
            }
        }
        // end if( count($colList) == 0)
        mysql_free_result($result);
        return $colList;
    } else {
        return false;
    }
}