Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DbRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function _dbLoadIfNotLoaded(): void
$sql = 'SELECT * FROM '.$connection->quoteIdentifier($this->dbTableName).' WHERE '.$sql_where;
$result = $connection->executeQuery($sql, $parameters);

$row = $result->fetch(\PDO::FETCH_ASSOC);
$row = $result->fetchAssociative();

if ($row === false) {
throw new TDBMException("Could not retrieve object from table \"$this->dbTableName\" using filter \".$sql_where.\" with data \"".var_export($parameters, true)."\".");
Expand Down
6 changes: 4 additions & 2 deletions src/QueryFactory/FindObjectsFromRawSqlQueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ private function formatSelect(array $baseSelect): array
}

$table = $this->schema->getTable($tableName);
$pkColumns = $table->getPrimaryKeyColumns();
$primaryKey = $table->getPrimaryKey();
assert($primaryKey !== null, 'TDBM Only works on tables with primary keys');
$pkColumns = $primaryKey->getUnquotedColumns();
foreach ($table->getColumns() as $column) {
$columnName = $column->getName();
$alias = AbstractQueryFactory::getColumnAlias($tableName, $columnName);
Expand All @@ -252,7 +254,7 @@ private function formatSelect(array $baseSelect): array
]
];
$formattedSelect[] = $astColumn;
if (array_key_exists($columnName, $pkColumns)) {
if (in_array($columnName, $pkColumns, true)) {
$formattedCountSelect[] = $astColumn;
}
$columnDescriptors[$alias] = [
Expand Down
4 changes: 1 addition & 3 deletions tests/Performance/ManyToOneBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace TheCodingMachine\TDBM\Performance;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\VoidCache;
use Doctrine\DBAL\Connection;
use Mouf\Database\SchemaAnalyzer\SchemaAnalyzer;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use TheCodingMachine\FluidSchema\TdbmFluidSchema;
use TheCodingMachine\TDBM\Configuration;
use TheCodingMachine\TDBM\ConfigurationInterface;
use TheCodingMachine\TDBM\ConnectionFactory;
use TheCodingMachine\TDBM\DummyGeneratorListener;
use TheCodingMachine\TDBM\SchemaLockFileDumper;
use TheCodingMachine\TDBM\TDBMAbstractServiceTest;
use TheCodingMachine\TDBM\TDBMSchemaAnalyzer;
Expand Down Expand Up @@ -70,7 +68,7 @@ private static function initSchema(Connection $connection): void
$sqlStmts = $toSchema->getMigrateFromSql($fromSchema, $connection->getDatabasePlatform());

foreach ($sqlStmts as $sqlStmt) {
$connection->exec($sqlStmt);
$connection->executeStatement($sqlStmt);
}

for ($i = 1; $i < 200; $i++) {
Expand Down
4 changes: 2 additions & 2 deletions tests/TDBMAbstractServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,12 @@ private static function initSchema(Connection $connection): void

foreach ($sqlStmts as $sqlStmt) {
//echo $sqlStmt."\n";
$connection->exec($sqlStmt);
$connection->executeStatement($sqlStmt);
}

// Let's generate computed columns
if ($connection->getDatabasePlatform() instanceof MySqlPlatform && !self::isMariaDb($connection)) {
$connection->exec('CREATE TABLE `players` (
$connection->executeStatement('CREATE TABLE `players` (
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`player_and_games` JSON NOT NULL,
`names_virtual` VARCHAR(20) GENERATED ALWAYS AS (`player_and_games` ->> \'$.name\') NOT NULL COMMENT \'@ReadOnly\',
Expand Down
2 changes: 0 additions & 2 deletions tests/Utils/BeanDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@

namespace TheCodingMachine\TDBM\Utils;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\VoidCache;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Mouf\Database\SchemaAnalyzer\SchemaAnalyzer;
use TheCodingMachine\TDBM\Configuration;
Expand Down
Loading