PDO::rowCount() returning -1

前端 未结 2 1731
不思量自难忘°
不思量自难忘° 2021-01-15 03:25

i have this function below. that i used to run on a MySQL DB. I had to move to a SQL Server 2008, easy thing.

But, after that, the rowCount()

2条回答
  •  失恋的感觉
    2021-01-15 03:38

    Got it guys.

    The prepare() statement should receive one more parameter. array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL) .

    $stmt = $this->pdo->prepare($sql,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));

    After that the rowCount() should work fine.

    Thanks for the answer @Rasclatt.

提交回复
热议问题