1

I am new to TYPO3, I am creating a php file in TYPO3. But don't know how to get database connection in that.

What are the dependency files and which object should use to get the database connection in my own custom file

I am using TYPO3 CMS - Professional Web Content Management System V-6.2.14

I am trying to store the user choice of language selection in the database. enter image description here Using AJAX I am going to post data to my own custom PHP file, in that php file I need to access database for select queries

ManiMuthuPandi
  • 1,594
  • 2
  • 26
  • 46
  • Please provide more information about your environment, like your TYPO3 version – Euli Jun 20 '17 at 12:10
  • I have added the details – ManiMuthuPandi Jun 20 '17 at 12:12
  • 1st: this version is **out of support.** 2nd: please give some more information what you want to do. there are some differences whether you want to build a plugin (Frontend), a backend-module or a CLI-command. In general: use the existing database connection by using the appropriate [classes](https://api.typo3.org/typo3cms/62/html/). especially as you will need to update the installation to a newer version. – Bernd Wilke πφ Jun 20 '17 at 12:19
  • Please also explain what you are actually trying to do, not how. It's not unlikely that there is a better approach. – Mathias Brodala Jun 20 '17 at 12:19
  • @BerndWilkeπφ and Mathias Brodala: I have explained my real time issue – ManiMuthuPandi Jun 20 '17 at 12:50
  • I hope accessing $GLOBALS['TSFE'] will get the database connection; How could I get this value in my own php file – ManiMuthuPandi Jun 20 '17 at 13:09

1 Answers1

1

one (clean) way to do ajax with TYPO3 is EID-Script.
Here is a good description: Connect to database with eID
be aware, that in this stub the fe-user is handled already:

$TSFE->initFEuser();

after that you could access the FE user record with

$GLOBALS['TSFE']->fe_user->user 
Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38