Hallo,
Ich versuche die Datensätze meiner eigenen extension nach einem Tabelleneintrag "sorting" zu sortieren um die gleiche Anzeige wie im backend zu realisieren. An dieser scheinbar einfachen Aufgabe scheitere ich gerade kläglich 😃
Im Moment sortiert meine Extension die Datensätze nach "crdate". Warum das so ist, weiß ich nicht.
Ich habe in der ext_tables.php der extension einen default_sortby Wert angegeben, aber es passiert garnix 😢
"default_sortby" => "ORDER BY sorting",
bin für jeden Hinweiß dankbar!
Du willst die Datensäte sortiert ausgeben?
dann musst du die tx_....pi1.php von deiner Ext ändern und dort die Abfrage anpassen!
lg georg
ok ... haste auch ne Idee wie ? nen Beispiel wäre cool !
siehe API:
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
$theTable,
$theField.'="'.
$GLOBALS['TYPO3_DB']->quoteStr($theValue, $theTable).'"'.
$this->deleteClause($theTable).' '.
$whereClause,
$groupBy,
$orderBy,
$limit
);
$rows = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$rows[] = $row;
}
so schaut eine typische ABfrage aus und beim orderBy gehört dein sorting rein
lg georg
dafür bin ich gerade irgentwie zu doof ... ich hol mir doch den tabelleninhalt mit der Funktion "pi_list_makelist" ... die macht doch die Abfrage für mich oder nicht ?
sorry, bin nich so der phpcrack :o
edit:
ok das
$rows = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$rows[] = $row;
}
wird vom pi_list_makelist ausgeführt.
gelöst
$res = $this->pi_exec_query('Tabellenname','','','','','sorting');
mehr aufschluss gibt die "class.tslib_pibase.php"
/**
* Executes a standard SELECT query for listing of records based on standard input vars from the 'browser' ($this->internal['results_at_a_time'] and $this->piVars['pointer']) and 'searchbox' ($this->piVars['sword'] and $this->internal['searchFieldList'])
* Set $count to 1 if you wish to get a count(*) query for selecting the number of results.
* Notice that the query will use $this->conf['pidList'] and $this->conf['recursive'] to generate a PID list within which to search for records.
*
* @param string The table name to make the query for.
* @param boolean If set, you will get a "count(*)" query back instead of field selecting
* @param string Additional WHERE clauses (should be starting with " AND ....")
* @param mixed If an array, then it must contain the keys "table", "mmtable" and (optionally) "catUidList" defining a table to make a MM-relation to in the query (based on fields uid_local and uid_foreign). If not array, the query will be a plain query looking up data in only one table.
* @param string If set, this is added as a " GROUP BY ...." part of the query.
* @param string If set, this is added as a " ORDER BY ...." part of the query. The default is that an ORDER BY clause is made based on $this->internal['orderBy'] and $this->internal['descFlag'] where the orderBy field must be found in $this->internal['orderByList']
* @param string If set, this is taken as the first part of the query instead of what is created internally. Basically this should be a query starting with "FROM [table] WHERE ... AND ...". The $addWhere clauses and all the other stuff is still added. Only the tables and PID selecting clauses are bypassed. May be deprecated in the future!
* @return pointer SQL result pointer
*/
function pi_exec_query($table,$count=0,$addWhere='',$mm_cat='',$groupBy='',$orderBy='',$query='')
{
$queryParts = $this->pi_list_query($table,$count,$addWhere,$mm_cat,$groupBy,$orderBy,$query, TRUE);
return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
}