Propel2 icon indicating copy to clipboard operation
Propel2 copied to clipboard

Non-static method Propel\Runtime\ActiveQuery\ModelCriteria::delete()` cannot be called statically

Open phpfui opened this issue 1 year ago • 2 comments

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:

	public function delete(?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(static function() use ($con, $criteria) {
			$affectedRows = 0; // initialize var to track total num of affected rows

			EmployeeTableMap::removeInstanceFromPool($criteria);

			$affectedRows += ModelCriteria::delete($con);  // this is line 222
			EmployeeTableMap::clearRelatedInstancePool();

			return $affectedRows;
		});
	}

phpfui avatar Jun 21 '24 16:06 phpfui