You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting the following error from the code generated by propel init:
Fatal error: Uncaught Error: Non-static method Propel\Runtime\ActiveQuery\ModelCriteria::delete()` cannot be called statically in C:\websites\php-orm-sql-benchmarks\SOB\Propel2\Base\EmployeeQuery.php on line 222
Indeed, ModelCriteria::delete is not static.
Running PHP 8.2.13 (but this is not a PHP issue, PHP is reported the error correctly)
Composer:
"propel/propel": "2.0.0-beta4",
The generated method in question:
publicfunctiondelete(?ConnectionInterface$con = null) : int
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(EmployeeTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName$criteria->setDbName(EmployeeTableMap::DATABASE_NAME);
// use transaction because $criteria could contain info// for more than one table or we could emulating ON DELETE CASCADE, etc.return$con->transaction(staticfunction() use ($con, $criteria) {
$affectedRows = 0; // initialize var to track total num of affected rowsEmployeeTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con); // this is line 222EmployeeTableMap::clearRelatedInstancePool();
return$affectedRows;
});
}
The text was updated successfully, but these errors were encountered:
Hey, I tired reproducing this in my project (php 8.3.6). Seems to work fine. Since the generated Query base classes inherit from ModelCriteria, ModelCriteria::delete($con) reads to me to be equivalent to parent::delete($con): http://php.adamharvey.name/manual/en/keyword.parent.php
It's not recommended, but still valid PHP.
I'm doing this on my end (on my implementation of an employee model): EmployeeQuery::create()->filterById(2)->delete()
I'm happy to try and help if you let me know if you see it differently or have more information.
So it looks like it should be parent::delete($con) and not ModelCriteria::delete($con).
I think this changed in a recent version of PHP. Because ModelCriteria::delete does not reference $this, it must be static. parent::delete has an implicit $this, so it calls the parent method, which is not static. That should work, but I don't know the code, which is why I asked.
Getting the following error from the code generated by
propel init
:Fatal error: Uncaught Error: Non-static method Propel\Runtime\ActiveQuery\ModelCriteria::delete()` cannot be called statically in C:\websites\php-orm-sql-benchmarks\SOB\Propel2\Base\EmployeeQuery.php on line 222
Indeed, ModelCriteria::delete is not static.
Running PHP 8.2.13 (but this is not a PHP issue, PHP is reported the error correctly)
Composer:
The generated method in question:
The text was updated successfully, but these errors were encountered: