steffen

Mitglieder
  • Gesamte Inhalte

    1
  • Registriert

  • Letzter Besuch

Ansehen in der Community

0 Neutral

Über steffen

  • Rang
    Mitglied

Kontakt

  • ICQ 0
  1. exec_SELECT_mm_query

    Ich baue an einer Extension mit Datenbankrelationen (1 echte M-M-Relation). Das funktioniert auch erstmal doch möchte ich von der foreign-Tabelle nicht nur das Verbindungsfeld, sondern auch die übrigen anzeigen lassen. Dabei muss mir jemand helfen. Local-Tabelle (tx_labis_find) – uid, number, fdate, name, location, who, image u.a. Foreign-Tabelle (tx_lapis_stone) – uid, name, max, min, components, description u.a. Foreign-Tabelle (tx_lapis_who) – uid, finder u.a. -egal Nun habe ich eine exec_SELECT_mm_query drin und habe versucht, mit sql_fetch_assoc zum Ziel zu kommen, doch meine Versuche haben nichts gebracht. Wer kann mein Script entsprechend ergänzen, so dass ich z.B. components auswerfen kann? <?php require_once(PATH_tslib.'class.tslib_pibase.php'); /** * Plugin 'Stone_Single_View' for the 'lapis' extension. * * @author    Steffen <steffen@mondfarben.de> * @package    TYPO3 * @subpackage    tx_lapis */ class tx_lapis_pi3 extends tslib_pibase {     var $prefixId      = 'tx_lapis_pi3';        // Same as class name     var $scriptRelPath = 'pi3/class.tx_lapis_pi3.php';    // Path to this script relative to the extension dir.     var $extKey        = 'lapis';    // The extension key.     var $pi_checkCHash = true;          /**      * Main method of your PlugIn      *      * @param    string        $content: The content of the PlugIn      * @param    array        $conf: The PlugIn Configuration      * @return    The content that should be displayed on the website      */     function main($content, $conf)    {         switch((string)$conf['CMD'])    {             case 'singleView':                 list($t) = explode(':',$this->cObj->currentRecord);                 $this->internal['currentTable']=$t;                 $this->internal['currentRow']=$this->cObj->data;                 return $this->pi_wrapInBaseClass($this->singleView($content, $conf));             break;             default:                 if (strstr($this->cObj->currentRecord,'tt_content'))    {                     $conf['pidList'] = $this->cObj->data['pages'];                     $conf['recursive'] = $this->cObj->data['recursive'];                 }                 return $this->pi_wrapInBaseClass($this->listView($content, $conf));             break;         }     }          /**      * Shows a list of database entries      *      * @param    string        $content: content of the PlugIn      * @param    array        $conf: PlugIn Configuration      * @return    HTML list of table entries      */     function listView($content, $conf) {         $this->conf = $conf;        // Setting the TypoScript passed to this function in $this->conf         $this->pi_setPiVarDefaults();         $this->pi_loadLL();        // Loading the LOCAL_LANG values                  $lConf = $this->conf['listView.'];    // Local settings for the listView function              if (is_numeric($this->piVars['showUid']))    {    // If a single element should be displayed:             $this->internal['currentTable'] = 'tx_lapis_find';             $this->internal['currentRow'] = $this->pi_getRecord('tx_lapis_find',$this->piVars['showUid']);      $this->internal['currentView'] = 'singleView';  // Frisch eingefügt             $content = $this->singleView($content, $conf);             return $content;         } else { $this->internal['currentView'] = 'listView';    //Frisch eingefügt             $items=array(                 '1'=> $this->pi_getLL('list_mode_1','Mode 1'),                 '2'=> $this->pi_getLL('list_mode_2','Mode 2'),                 '3'=> $this->pi_getLL('list_mode_3','Mode 3'),             );             if (!isset($this->piVars['pointer']))    $this->piVars['pointer']=0;             if (!isset($this->piVars['mode']))    $this->piVars['mode']=1;                      // Initializing the query parameters:             list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']);             $this->internal['results_at_a_time']=t3lib_div::intInRange($lConf['results_at_a_time'],0,10,10);        // Number of results to show in a listing.             $this->internal['maxPages']=t3lib_div::intInRange($lConf['maxPages'],0,1000,2);;        // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.             $this->internal['searchFieldList']='number,location,name,who,lat,lon,details';                 //        geändert                 $this->internal['orderByList']='uid,number,fdate,name,location,lat,lon';                      // Get number of records:             //$res = $this->pi_exec_query('tx_lapis_find',1); // Frisch eingefügt     if ($this->piVars['showCat']) { $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('count(tx_lapis_find.uid)','tx_lapis_find','tx_lapis_find_name_mm','tx_lapis_stone',' AND tx_lapis_find_name_mm.uid_foreign='.$this->piVars['showCat']); }else{ $res = $this->pi_exec_query('tx_lapis_find',1); }                            list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);                      // Make listing query, pass query to SQL database:             //$res = $this->pi_exec_query('tx_lapis_find'); // Frisch eingefügt     if ($this->piVars['showCat']) { $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_lapis_find.*','tx_lapis_find','tx_lapis_find_name_mm','tx_lapis_stone',' AND tx_lapis_find_name_mm.uid_foreign='.$this->piVars['showCat']); }else{ $res = $this->pi_exec_query('tx_lapis_find'); }             $this->internal['currentTable'] = 'tx_lapis_find';                      // Put the whole list together:             $fullTable='';    // Clear var;         #    $fullTable.=t3lib_div::view_array($this->piVars);    // DEBUG: Output the content of $this->piVars for debug purposes. REMEMBER to comment out the IP-lock in the debug() function in t3lib/config_default.php if nothing happens when you un-comment this line!                      // Adds the mode selector.             // $fullTable.=$this->pi_list_modeSelector($items);                      // Adds the search box:             $fullTable.=$this->pi_list_searchBox();                          // Adds the whole list table             $fullTable.=$this->pi_list_makelist($res);                           // Adds the result browser:             $fullTable.=$this->pi_list_browseresults();                      // Returns the content from the plugin.             return $fullTable;         }     }     /**      * Display a single item from the database      *      * @param    string        $content: The PlugIn content      * @param    array        $conf: The PlugIn configuration      * @return    HTML of a single database entry      */     function singleView($content, $conf) {         $this->conf = $conf;         $this->pi_setPiVarDefaults();         $this->pi_loadLL();                           // This sets the title of the page for use in indexed search results:         if ($this->internal['currentRow']['title'])    $GLOBALS['TSFE']->indexedDocTitle=$this->internal['currentRow']['title'];              $content='<div'.$this->pi_classParam('singleView').'>             <p>'.$this->internal['currentRow']['uid'].''.'</p>             <H3'.$this->pi_classParam("singleViewField-number").'> '.$this->getFieldContent('number').'</H3>             <hr />                                 <p class="steinbild"> '.$this->getFieldContent('image').'</p>                 <span><p'.$this->pi_classParam("singleViewField-fdate").'><strong>'.$this->getFieldHeader('fdate').':</strong> '.$this->getFieldContent('fdate').'                 &nbsp;&nbsp;<strong>'.$this->getFieldHeader('location').':</strong> '.$this->getFieldContent('location').'</p></span>                 <span><p'.$this->pi_classParam("singleViewField-lat").'><strong>'.$this->getFieldHeader('lat').':</strong> '.$this->getFieldContent('lat').'                 &nbsp;&nbsp;<strong>'.$this->getFieldHeader('lon').':</strong> '.$this->getFieldContent('lon').'</p></span>                                 <p'.$this->pi_classParam("singleViewField-name").'><strong>'.$this->getFieldHeader('name').':</strong> '.$this->getFieldContent('name').'</p>                 <p'.$this->pi_classParam("singleViewField-who").'><strong>'.$this->getFieldHeader('who').':</strong> '.$this->getFieldContent('who').'</p>                <p'.$this->pi_classParam("singleViewField-details").'><strong>'.$this->getFieldHeader('details').':</strong> '.$this->getFieldContent('details').'</p> <p'.$this->pi_classParam("singleViewField-components").'><strong>'.$this->getFieldHeader('components').':</strong> '.$this->getFieldContent('tx_lapis_stone.components').'</p>         <p>'.$this->pi_list_linkSingle($this->pi_getLL('back','Back'),0).'</p></div>'.         $this->pi_getEditPanel();              return $content;         return $res;     }     /**      * Returns a single table row for list view      *      * @param    integer        $c: Counter for odd / even behavior      * @return    A HTML table row      */     function pi_list_row($c)    {         $editPanel = $this->pi_getEditPanel();         if ($editPanel)    $editPanel='<TD>'.$editPanel.'</TD>';              return '<tr'.($c%2 ? $this->pi_classParam('listrow-odd') : '').'>                 <td valign="top"><p>'.$this->getFieldContent('uid').'</p></td>                 <td valign="top"><p><strong>'.$this->getFieldContent('number').'</strong></p></td>                 <td valign="top"><p>'.$this->getFieldContent('fdate').'</p></td>                 <td valign="top"><p>'.$this->getFieldContent('name').'</p></td>                 <td valign="top"><p>'.$this->getFieldContent('location').'</p></td>                 <td valign="top"><p>'.$this->getFieldContent('who').'</p></td>                 <td valign="top"><p>'.$this->getFieldContent('image').'</p></td>                              </tr>';     }     /**      * Returns a table row with column names of the table      *      * @return    A HTML table row geändert      */     function pi_list_header()    {         return '<tr'.$this->pi_classParam('listrow-header').'>                 <td class="td_uid"><p>'.$this->getFieldHeader_sortLink('uid').'</p></td>                 <td class="td_number"><p>'.$this->getFieldHeader_sortLink('number').'</p></td>                             <td class="td_fdate"><p>'.$this->getFieldHeader_sortLink('fdate').'</p></td>                 <td class="td_name"><p>'.$this->getFieldHeader_sortLink('name').'</p></td>                 <td class="td_location"><p>'.$this->getFieldHeader_sortLink('location').'</p></td>                 <td class="td_who"><p>'.$this->getFieldHeader('who').'</p></td>                 <td class="td_image"><p>'.$this->getFieldHeader('image').'</p></td>                              </tr>';     }     /**      * Returns the content of a given field          *      * @param    string        $fN: name of table field      * @return    Value of the field      */     function getFieldContent($fN)    {         switch($fN) {             case 'uid':                 return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1);    // The "1" means that the display of single items is CACHED! Set to zero to disable caching.             break;             case "fdate":                     // For a numbers-only date, use something like: %d-%m-%y                 return strftime('%d. %m. %Y',$this->internal['currentRow']['fdate']);             break; // Frisch eingefügt             case "image":     $this->uploadPath = 'uploads/tx_'.$this->extKey.'/';   $view = $this->internal['currentView'];   $this->conf[$view.'.']['image.'][file] = $this->uploadPath.$this->internal ['currentRow'] [$fN];   return $this->cObj->IMAGE($this->conf[$view.'.'] ['image.']); break; case "name": if ($this->internal['currentRow'][$fN] != 0) { $return = ''; // Eine Datenabfrage über die M-M-Relation absetzen $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_lapis_stone.uid,tx_lapis_stone.name','tx_lapis_find','tx_lapis_find_name_mm','tx_lapis_stone',' AND tx_lapis_find_name_mm.uid_local='.$this->internal ['currentRow']['uid']); // Für jedes Ergebnis den Titel mit showCat-Parameter verlinken while ($obj = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $cat[] = $this->pi_linkTP_keepPIvars($obj['name'], array('showCat'=>$obj['uid'])); } if (is_array($cat)) { $return = implode(' ',$cat); } } return $return; break;              case "who":     $return = '';     $who = split(',',$this->internal['currentRow'][$fN]);     foreach ($who as $elem) {         $obj = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_lapis_who','uid='.$elem);             $wer[] = $obj [0] ['finder'];     }     if (is_array($who)) {         $return = implode(', ',$wer);     }     return $return;     break;             default:                 return $this->internal['currentRow'][$fN];             break;         }     }     /**      * Returns the label for a fieldname from local language array      *      * @param    [type]        $fN: ...      * @return    [type]        ...      */     function getFieldHeader($fN)    {         switch($fN) {                          default:                 return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']');             break;         }     }          /**      * Returns a sorting link for a column header      *      * @param    string        $fN: Fieldname      * @return    The fieldlabel wrapped in link that contains sorting vars      */     function getFieldHeader_sortLink($fN)    {         return $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1)));     } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lapis/pi3/class.tx_lapis_pi3.php'])    {     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lapis/pi3/class.tx_lapis_pi3.php']); } ?>