我正试图运行由其他团队开发的代码。我配置并运行项目,但我得到以下错误,这对我来说是新的。
严格标准:DB_Statement_1::execute()的声明应该是兼容PDOStatement::execute($bound_input_params = NULL) in/virtualhosts/libution/DB/Statement.1.php on line 12
严格标准:DB_Statement_1::fetch()的声明应该与PDOStatement::fetch($how = NULL, $orientation = NULL)兼容,$offset = NULL)在/virtualhosts/libution/DB/Statement.1.php中12
第12行在这里。
/**
* A statement class that implements DB_IStatement_1
* NOTE: in most cases, you should be type-hinting for DB_IStatement_1
* @author Andrew Minerd <andrew.minerd@sellingsource.com>
*/
following line is #12
class DB_Statement_1 extends PDOStatement implements DB_IStatement_1
{ public function execute(array $args = NULL)
{
// apparently, PDO counts the number of arguments to indicate missing
// optional parameters, rather than relying on a default value
$result = ($args !== NULL)
? parent::execute($args)
: parent::execute();
if ($result === FALSE)
{
throw new PDOException('Could not execute statement');
}
return $result;
}
/**
* Fetches a single row
*
* @param int $fetch_mode
* @return mixed
*/
public function fetch($fetch_mode = DB_IStatement_1::FETCH_ASSOC)
{
return parent::fetch($fetch_mode);
}
同一个包中有以下类:
DatabaseConfigPool.1.php MSSQLAdapter.1.php MySQL4Adapter.1.php ODBCConfig.1.php TransactionAbortedException.1.php
EmulatedPrepare.1.php MSSQLAdapterException.1.php MySQL4AdapterException.1.php PoolConfig.1.php TransactionManager.1.php
FailoverConfig.1.php MSSQLConfig.1.php MySQL4StatementAdapter.1.php Profiler Util
IConnection.1.php MSSQLConfig.2.php MySQLConfig.1.php Query.1.php Util.1.php
IDatabaseConfig.1.php MSSQLStatementAdapter.1.php MySQLiAdapter.1.php SQLiteConfig.1.php
IStatement.1.php MultiplexConfig.1.php MySQLiAdapterException.1.php Statement.1.php
[vendorapi@808680-app2 DB]$ nano Statement.1.php
表示它们中的哪一个被重写了。
thanks to all
这可能是由于PHP版本的升级,以及PHP在PHP 5.4+中处理不同错误的方式
首先,你可以禁用严格错误来摆脱这个错误,像这样:
error_reporting(E_ALL ^ E_STRICT);
注意E_STRICT -这是PHP 5.4+的新特性
但是,如果您想保留严格的错误,您可以通过更改代码来消除它们。你需要确保重写的类有正确的原型/定义来消除这个错误。
案例1)
class DB_Statement_1 extends PDOStatement implements DB_IStatement_1
{
public function execute($args = NULL) { ... }
....
}
删除'array'类型提示,因为父类没有,这应该使您摆脱第一个错误等