Skip to content

Cannot execute queries while other unbuffered queries are active - Migrate tool #5

@BugQuest

Description

@BugQuest

When use migration tool from 1.3, i have this error:

Fatal error: Uncaught orm\Exceptions\MigrationException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in E:\Projets\Web\htdocs\BugQuestTinyHouseServer\vendor\sagrishin\lightweight-php-orm\lib\orm\DataBase\Table.php:64 Stack trace: #0 E:\Projets\Web\htdocs\MyApp\app\Entity\Database.php(21): orm\DataBase\Table->migrate() #1 E:\Projets\Web\htdocs\MyApp\htdocs\index.php(9): App\Entity\Database::INIT() #2 {main} thrown in E:\Projets\Web\htdocs\MyApp\vendor\sagrishin\lightweight-php-orm\lib\orm\DataBase\Table.php on line 64

With juste simple user class:

class User extends Table
{
    public $id;
    public $pseudo;
    public $login;
    public $password;
    public $lastLogin;

    public function __construct(int $id = null)
    {
        $this->table_name = "bqth_user";
        $this->id = Field::primaryKey();
        $this->pseudo = Field::varchar(64);
        $this->login = Field::varchar(64);
        $this->password = Field::text();
        $this->lastLogin = Field::dateTime();

        $this->initTable();
    }
}
$db = new self();
$user = new User();
$user->migrate();`

Solution:
In QueryExecutor.php line 118:

    public function executeSql()
    {
        $this->execute();
        $this->pdo->commit();
    }

Just add:

    public function executeSql()
    {
        $this->execute();
        $this->query->closeCursor();
        $this->pdo->commit();
    }

And everything works ;3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions