for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Smoren\QueryRelationManager\Pdo;
use Smoren\QueryRelationManager\Base\QueryRelationManagerBase;
use Smoren\QueryRelationManager\Base\QueryWrapperInterface;
use Smoren\QueryRelationManager\Base\QueryRelationManagerException;
/**
* QueryRelationManager implementation for PDO
* @author Smoren <[email protected]>
*/
class QueryRelationManager extends QueryRelationManagerBase
{
* @inheritDoc
protected function getTableName(string $className): string
return $className;
}
protected function createQuery(): QueryWrapperInterface
return new QueryWrapper();
* @throws QueryRelationManagerException
protected function getTableFields(string $className): array
$qw = new QueryWrapper();
$qw->setRawSql('SHOW COLUMNS FROM '.addslashes($className));
$rows = $qw->all();
/** @var array<string> $result */
$result = [];
foreach($rows as $row) {
$result[] = $row['Field'];
return $result;
protected function getPrimaryKey(string $className): array
$qw->setRawSql("SHOW COLUMNS FROM `".addslashes($className)."` WHERE `Key` = 'PRI'");