简体   繁体   English

TYPO3扩展中的动态数据库登录

[英]Dynamic DB login in TYPO3 extension

So I want to build an extension, where you can export the data via php to excel or something similar. 所以我想构建一个扩展,你可以通过php将数据导出到excel或类似的东西。 Since I'm planning to distribute it, until now not sure if public or just to my close web-dev-friends, it wouldn't be a good idea to connect to the DB by typing in my credentials directly. 由于我计划分发它,直到现在不确定是公开还是仅仅关闭我的网络开发者朋友,通过直接输入我的凭证连接到数据库不是一个好主意。

Is there a way to import them from the LocalConfiguration.php file? 有没有办法从LocalConfiguration.php文件导入它们? In this way, it will also always work on other installations of T3. 通过这种方式,它也将始终适用于T3的其他安装。

Another or even a better way would be the T3-API, were I did only understand train-station (German proverb). 另一个甚至更好的方法是T3-API,我只是了解火车站(德国谚语)。 T3-API sounds like C3-POs best friend, though. 但是,T3-API听起来像C3-PO最好的朋友。

You might have noticed that I'm quite new to php and file-generation is maybe a little big task to set oneself. 您可能已经注意到我对php很新,文件生成可能是设置自己的一项大任务。 But without challenge, it wouldn't be fun, right? 但没有挑战,它就不会有趣,对吧?

Environment: TYPO3 7.4.0 // MySQL 5.5.46 // PHP Version 5.6.14 环境: TYPO3 7.4.0 // MySQL 5.5.46 // PHP版本5.6.14

You should use the TYPO3 database connection, which is available in the variable $GLOBALS['TYPO3_DB'] (not sure if there is a better way in newer TYPO3 versions). 您应该使用TYPO3数据库连接,该连接在变量$GLOBALS['TYPO3_DB']可用(不确定在较新的TYPO3版本中是否有更好的方法)。 This connection is automatically created from the database info in LocalConfiguration.php . 此连接是从LocalConfiguration.php的数据库信息自动创建的。

The variable is of type \\TYPO3\\CMS\\Core\\Database\\DatabaseConnection , the API documentation can be found here . 该变量的类型为\\TYPO3\\CMS\\Core\\Database\\DatabaseConnection ,可在此处找到API文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM