[TYPO3-english] ajax in fe extension - database connection

Dmitry Dulepov dmitry at typo3.org
Wed Apr 1 17:10:07 CEST 2009


Hi!

Michael Fischer wrote:
> I'm trying to implement a simple fe-plugin to display some data out of
> my database. I use ajax to display the data, i.e. after searching.
> 
> Here's my problem:
> In my fe-plugin I submit an ajax-request to a php-script on my
> webserver. I use the php-script to process the request and return the
> desired data (html-code). Of course I cannot access the typo3-database
> via $GLOBALS['TYPO3_DB'] in my php-script.
> 
> Does anybody know a way to use the typo3 database-functions in a script
> that is not a typo3-extension class?

require_once(t3lib_extMgm::extPath('cms', 'tslib/class.tslib_eidtools.php'));

....

class tx_foo_bar {
	function __construct() {
		tslib_eidtools::connectDB();
	}

	function main() {
		$GLOBALS['TYPO3_DB']->..........
	}
}

Buy the book and you will not need to ask such questions :) Here is the book:
http://www.packtpub.com/typo3-extension-development/book

-- 
Dmitry Dulepov
Skype: liels_bugs
In the blog: http://dmitry-dulepov.com/article/automatic-realurl-configuration-howto.html


More information about the TYPO3-english mailing list