Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MS SQL准备执行PHP_Php_Sql Server_Database_Sql Server 2008 - Fatal编程技术网

MS SQL准备执行PHP

MS SQL准备执行PHP,php,sql-server,database,sql-server-2008,Php,Sql Server,Database,Sql Server 2008,我对MS Sql和一些php查询一窍不通 function getBillet($idBillet) { $connection = getBdd(); $sql = 'select BIL_ID as id, BIL_DATE as date, BIL_TITRE as titre, BIL_CONTENU as contenu from t_billet where BIL_ID=?'; $billet = $connection->

我对MS Sql和一些php查询一窍不通

function getBillet($idBillet) {

    $connection = getBdd();
    $sql = 'select BIL_ID as id, BIL_DATE as date,
      BIL_TITRE as titre, BIL_CONTENU as contenu from t_billet
       where BIL_ID=?';
    $billet = $connection->prepare($sql);
    $billet->execute(array($idBillet));

    if ($billet->rowCount() == 1)
        return $billet->fetch();
    else
        throw new Exception('Aucun billet ne correspond à l\'identifiant' . $idBillet . ' ');
}
这一行不起作用,我正在尝试获取在参数上插入ID的行。 与数据库的连接工作正常,但我无法使查询正常工作。特别是因为谷歌上的所有信息都是关于MySQL的,而关于MS SQL的信息却很少。 这个很好用,例如:

function getBillets() {
$connection = getBdd();
$sql = 'select BIL_ID as id, BIL_DATE as date,
      BIL_TITRE as titre, BIL_CONTENU as contenu from t_billet
       order by BIL_ID desc';
$result = $connection->query($sql);
$resultat = $result->fetchAll();

return $resultat;
}

提前谢谢。

这台坏了怎么办?犯错误?给予你不期望的东西?不给你你所期望的?什么是不工作?它是否返回任何内容,抛出异常?它不显示任何内容,不显示错误或任何结果。您是否尝试过简单地测试prepare和execute是否返回false,如果返回false,则输出数据库错误。查看您如何连接到数据库可能会很有用此数据库不起作用?犯错误?给予你不期望的东西?不给你你所期望的?什么是不工作?它是否返回任何内容,抛出异常?它不显示任何内容,不显示错误或任何结果。您是否尝试过简单地测试prepare和execute是否返回false,如果返回false,则输出数据库错误。查看如何连接到数据库可能很有用