-
-
Save JPDesign/e3fcad0cf40fc30d2b9307c82ab2766a to your computer and use it in GitHub Desktop.
Revisions
-
einpraegsam revised this gist
Jun 16, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,12 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; // select * from tt_content where colPos=0 limit 3; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('*') ->from('tt_content') ->where('colPos=0') ->orderBy('sorting') ->setMaxResults(3) ->execute(); -
einpraegsam renamed this gist
Jun 15, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
einpraegsam revised this gist
Jun 15, 2017 . No changes.There are no files selected for viewing
-
einpraegsam revised this gist
Jun 15, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; // insert into tt_content (header, crdate, pid) VALUES ("New content", 123456789, 123); $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $queryBuilder ->insert('tt_content') -
einpraegsam revised this gist
Jun 15, 2017 . 5 changed files with 21 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; // insert into $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $queryBuilder ->insert('tt_content') @@ -10,4 +11,4 @@ 'crdate' => time(), 'pid' => 123, ]) ->execute(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,4 +13,7 @@ exec_UPDATEquery() exec_INSERTquery() Nevertheless there is a QueryBuilder class that can be used. I played a bit with it in TYPO3 8.7.1 and stored some examples for me and of course for everybody who wants to know. Find out more in the documentation: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Database/QueryBuilder/Index.html or in the PHP Class \TYPO3\CMS\Core\Database\Query\QueryBuilder This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; // select * from tt_content where hidden=0 and colPos=0 limit 3; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('*') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; // select header from tt_content where colPos=0; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('header') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <?php use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; // update tt_content set header = "new" where uid = 120; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->eq('uid', 120) // if 120 would be a user parameter, use $queryBuilder->createNamedParameter($param) for security reasons ) ->set('header', 'new') ->execute(); -
einpraegsam revised this gist
Jun 15, 2017 . 2 changed files with 20 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <?php use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $queryBuilder ->insert('tt_content') ->values([ 'header' => 'New content', 'crdate' => time(), 'pid' => 123, ]) ->execute(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,8 @@ I'm inspired through the slides from the talk from Nicole (see https://de.slideshare.net/cpsitgmbh/certifuncation-2017-best-practices-extension-development-for-typo3-8-lts) and doctrine in TYPO3. As far as I understand the variable $GLOBALS['TYPO3_DB'] which contains the DatabaseConnection class will not be available in future versions of TYPO3. That means that common functions are not available any more: exec_SELECTquery() @@ -9,4 +12,5 @@ exec_DELETEquery() exec_UPDATEquery() exec_INSERTquery() Nevertheless there is a QueryBuilder class that can be used. I played a bit with it in TYPO3 8.7.1 and stored some examples for me and of course for everybody who wants to know. -
einpraegsam revised this gist
Jun 15, 2017 . 3 changed files with 18 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,12 @@ I'm inspired through the slides from the talk from Nicole (see https://de.slideshare.net/cpsitgmbh/certifuncation-2017-best-practices-extension-development-for-typo3-8-lts) and doctrine in TYPO3. As far as I understand the variable $GLOBALS['TYPO3_DB'] which contains the DatabaseConnection class will not be available in future versions of TYPO3. That means that common functions are not available any more: exec_SELECTquery() exec_SELECTgetRows() exec_SELECTgetSingleRow() exec_DELETEquery() exec_UPDATEquery() exec_INSERTquery() Nevertheless there is a QueryBuilder class that can be used. I played a bit with it in TYPO3 8.7.1 and stored some examples for me and of course for everybody who wants to know. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ <?php use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('*') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ <?php use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('header') -
einpraegsam revised this gist
Jun 15, 2017 . 4 changed files with 14 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ My Text This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('*') @@ -6,4 +7,5 @@ ->orderBy('sorting') ->setMaxResults(3) ->execute(); $rows = $result->fetchAll(); var_dump($rows); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ <?php $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('header') ->from('tt_content') ->where('colPos=0') ->execute(); while ($row = $result->fetch()) { var_dump($row); } -
einpraegsam created this gist
Jun 15, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); $result = $queryBuilder ->select('*') ->from('tt_content') ->where('hidden = 0 and colPos = 0') ->orderBy('sorting') ->setMaxResults(3) ->execute(); $rows = $result->fetchAll(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ My text