Get Statement无法在zend2中使用sql生成


Getting Statement couldn't be produced with sql in zend2?

这是我在模型中的函数:

public function user_login($getData,$session_id){ // manage the user's login 
        $email = $getData['login_email'];
        $password  = $getData['login_password'];
        $select = $this->adapter->query("select count(*) as counter from users where email = '$email' and  password = '".md5($password)."'");
        $results = $select->execute();
        if ($results->current()['counter'] == 1 ){
            $update = $this->adapter->query("update users set session_id = '".$session_id."' where email = '".$email."'");
            $update_session = $update->execute();
            return 1; 
        }else{
            return 0;
        }
    }

当我执行计数查询时,它可以工作,并且我也使用此方法从查询中获取值或在数据库中插入数据。 但是现在我想做一个简单的更新,由于某种原因不起作用。我不知道为什么?为什么我会收到此消息?

更新:这是我的模块名称文件夹中的模块.php文件的内容:

namespace Application;
use Zend'Mvc'ModuleRouteListener;
use Zend'Mvc'MvcEvent;
class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        $eventManager        = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);
    }
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }
    public function getAutoloaderConfig()
    {
        return array(
            'Zend'Loader'StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
    public function getServiceConfig() {
        return array(
            'factories' => array(
                'Application'Model'UsersTable' => function($sm) {
                    $dbAdapter = $sm->get('Zend'Db'Adapter'Adapter');
                    $table = new Model'UsersTable($dbAdapter);
                    return $table;
                },
            ),
        );
    }
}

有同样的问题,在这里找到了解决方案。

可能是未缓冲的查询?

$statement = $adapter->query("SELECT ...");
$result = $statement->execute();
$result->buffer();
// validate your result