mysql pdo rowcount_PDO rowCount()在MySQL上有效,但在SQL Server 2008 R...

当我在SQL Server 2008中获得行数时遇到问题,因为我的代码使用MySQL可以正常运行,但在SQL Server中却不能.

$sql = "SELECT TOP 1 U.Id , U.Name, U.Profile, P.Name NameProfile

FROM sa_users U

INNER JOIN sa_profiles P ON P.Id = U.Profile

WHERE User = :user AND Pass = :pass";

$result = $this->dbConnect->prepare($sql) or die ($sql);

$result->bindParam(':user',$this->data['username'],PDO::PARAM_STR);

$result->bindParam(':pass',$this->data['password'],PDO::PARAM_STR);

if (!$result->execute()) {

return false;

}

$numrows = $result->rowCount();

$jsonLogin = array();

var_dump($numrows);

if($numrows > 0) {

while ($row = $result->fetch(PDO::FETCH_ASSOC)) {

$jsonLogin = array(

'name' => $row['Name'],

'id' => $row['Id'],

'profile' => $row['Profile'],

'n_profile' => $row['NameProfile']

);

}

$jsonLogin['area'] = 'another';

return $jsonLogin;

} else {

return false;

}

MySQL和SQL Server中的var_dump($result-> fetch())

array(8) {

["Id"]=>

string(1) "1"

[0]=>

string(1) "1"

["Nombre"]=>

string(13) "Administrador"

[1]=>

string(13) "Administrador"

["Perfil"]=>

string(1) "1"

[2]=>

string(1) "1"

["NomPerfil"]=>

string(13) "Administrador"

[3]=>

string(13) "Administrador"

}

SQL Server中的var_dump($numrows)

int(-1)

MySQL中的var_dump($numrows)

int(1)

问候.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值