【问题标题】:Array to string conversion SQL Symfony [duplicate]数组到字符串的转换SQL Symfony [重复]
【发布时间】:2015-11-24 14:28:23
【问题描述】:

我有一个 sql 请求:

$listUsers=$connection->prepare("SELECT u.id as userid From user u , account a where a.id_parent=$id_account OR  a.id=$id_account and u.id_account=a.id ");
    $listUsers->execute();
    $users=$listUsers->fetchAll();

此请求为我返回用户 ID 列表。

我有另一个要求:

             $listPush=$connection->prepare("select id from table_names where id_user in (?)");
        $listPush->bindValue(1, $users);
        $listPush->execute();

但是这样不行,我用implode来提取用户的id还是不行。

    at ErrorHandler ->handleError ('8', 'Array to string conversion', 'C:\wamp\www\CleverMultimedias\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php', '67', array('param' => '1', 'value' => array(array('userid' => '10')), 'type' => '2')) 
at PDOStatement ->bindValue ('1', array(array('userid' => '10')), '2') 

有什么建议

【问题讨论】:

    标签: php sql symfony


    【解决方案1】:

    我认为您的 $users 应该等于“1,2,3,4”之类的字符串,而不是数组

    【讨论】:

      猜你喜欢
      • 2016-04-28
      • 1970-01-01
      • 2017-11-23
      • 2021-12-04
      • 2015-09-09
      • 1970-01-01
      • 2014-08-30
      • 2017-09-22
      • 2013-12-05
      相关资源
      最近更新 更多