Skip to content

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

@phpfui

Description

@phpfui

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;
		});
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions