Created
March 1, 2019 11:23
-
-
Save calien666/e8000c9e6a0178cfa2998bda763df5f6 to your computer and use it in GitHub Desktop.
Prepared statements in TYPO3
This file contains 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 characters
<?php | |
$connectionPool = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class); | |
$productConnection = $connectionPool->getConnectionForTable('tx_myext_domain_model_mytable'); | |
$productDB = $productConnection->createQueryBuilder(); | |
$prepSelect = $productDB->select('*') | |
->from('tx_myext_domain_model_mytable') | |
->where( | |
$productDB->expr()->eq('uid', $productDB->createPositionalParameter(0, \PDO::PARAM_INT)) | |
)->getSQL(); | |
$statement = $productConnection->prepare($prepSelect); | |
foreach ($myData as $data) { | |
$statement->bindValue(1, $data['uid']); | |
$statement->execute(); | |
$result = $statement->fetch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment