我以为我可以直接调用一个方法,classname::method
但它没有用。这怎么可能?我用 xdebug 跟踪了函数调用,但它给了我一个错误。当方法需要一些类变量时会不会有问题?
这有效:
$a = new export_csv();
$a->dl_csv();
这不:export_csv::dl_csv();
我在我的方法中添加了公共静态无济于事。我在日志文件中没有得到任何东西,并且 xdebug 停止工作而没有错误消息?这是正常的吗?我的课程包括一些课程并连接到我的数据库并提取和回显一些行?
require_once(PATH_t3lib.'class.t3lib_db.php');
require_once(PATH_t3lib.'class.t3lib_div.php');
require_once(PATH_t3lib.'utility/class.t3lib_utility_math.php');
class export_csv
{
var $filename = 'meinname.csv';
public static function dl_csv()
{
// bitte nicht ändern muß zur laufzeit geladen werden
include(PATH_typo3conf.'localconf.php');
$GLOBALS['TYPO3_DB'] = t3lib_div::makeInstance('t3lib_DB');
$GLOBALS['TYPO3_DB']->connectDB($typo_db_host, $typo_db_username,
$typo_db_password, $typo_db);
session_start();
$targetCat = mysql_real_escape_string($_SESSION['targetCat']);
// calculate the number of rows for the query. We need this for paging the
result
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'V.title VT, V.uid VU,
S.title ST, S.uid SU, S1.uid S1U, S1.title S1T',
'tx_category V
INNER JOIN tx_category S ON
V.parent_category=S.uid
INNER JOIN tx_category S1 ON
S.parent_category=S1.uid',
'V.uid='.$targetCat.' OR S.uid='.
$targetCat.' OR S1.uid='.
$targetCat.
' AND V.deleted=0 AND V.hidden=0',
'',
'',
''
);
$arrcount=0;
while ( $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res) )
{
$categories[] = mysql_real_escape_string($row["VU"]);
++$arrcount;
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type:text/comma-separated-values");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=$this->filename");
if ( $arrcount )
{
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',
'tx_download',
'category IN('.implode(",",
$categories).")",
'',
"",
""
);
while ($row = mysql_fetch_assoc($res) )
{
$s = array ();
$s[] = $row['1'];
$s[] = $row['2'];
$s[] = $row['3'];
$s[] = $row['4'];
$s[] = $row['5'];
echo '"'. substr ( implode ( '","', $s ),0,strlen ( implode ( '","', $s) ) - 2 ) . "\r\n";
}
}
}
}