Skip to content

Instantly share code, notes, and snippets.

@calien666
Created March 1, 2019 11:23
Show Gist options
  • Save calien666/e8000c9e6a0178cfa2998bda763df5f6 to your computer and use it in GitHub Desktop.
Save calien666/e8000c9e6a0178cfa2998bda763df5f6 to your computer and use it in GitHub Desktop.
Prepared statements in TYPO3
<?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