我在PHP 7上使用drupal 7,在Windows上的Xampp上工作,突然间我开始收到以下错误:
Call to undefined method DatabaseStatementBase::setFetchMode()
Run Code Online (Sandbox Code Playgroud)
DatabaseStatementBase直接扩展PDOStatement的位置.将代码减少到以下最小值时:
<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', 'test', 'test');
$pdostatement = $dbh->prepare('SELECT * FROM items WHERE id=?');
$pdostatement->setFetchMode(PDO::FETCH_CLASS);
$success = $pdostatement->execute([1]);
// do stuff...
Run Code Online (Sandbox Code Playgroud)
它仍会在有关setFetchMode的行上引发错误.当我对该行进行注释时,不会抛出任何错误,但是我得到了一个关联数组而不是一个对象 - 而不是drupal所期望的.特别是因为setFetchMode应该存在(参见http://php.net/manual/en/pdostatement.setfetchmode.php)
最后,当我尝试找到$pdostatement
使用反射的方法时,我得到一些名称的垃圾 - 或者更确切地说,名称似乎长约1.5MB并且包含许多不可读的字符和一些方法名称,好像整个DLL都加载在那里或其他东西.这是var_dump
(php7和xdebug)的一个例子:
object(ReflectionMethod)[17]
public 'name' => string '????&??????p?aZ???????????? ???bindParam???????{?nZ???????????????setAttribute????f?kZ??????????j????FETCH_ORI_FIRST?a?pZ?????????q??
???CURSOR_SCROLL???l?}Z???????????????fetchColumn??????zZ??????????????wph?????&????????Z???????????????debugDumpParams???Z????????.?????children??????????Z????????????wphX????&????????Z????????(??
???nextrowset????????Z????????????
???__toString?????? ??Z????????????wph(????&??????4??Z????????'... (length=1752201104)
public 'class' => string 'PDOStatement' (length=12)
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
PhpStorm检查声称在第二种情况下休息后的所有内容都无法访问.我不明白为什么.我错过了什么?
function mymodule_admin_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'taxonomy_overview_terms':
// We need to add a submit handler to this form so we can save the weight
// in Mongo.
$form['#submit'][] = 'mymodule_admin_taxonomy_overview_submit_mongo';
break;
// Unwraps the mymodule News node form
case 'mymodule_news_node_form':
$form['#nowrap'] = true;
$form['field_news_image']['#prefix'] = '<div class="row"><div class="large-5 columns">';
$form['field_news_image']['#suffix'] = '</div></div>';
$form['actions']['#prefix'] = '<div class="row"><div class="large-3 columns actions">';
$form['actions']['#suffix'] = '</div></div>';
break; // PhpStorm claims everything after this is unreachable ******
// Unwraps the page …
Run Code Online (Sandbox Code Playgroud)