1

I've been given an stored procedure that is called like this:

SP_REPORT_HOME 'param1','param2',1

It executes a bunch of code i'm not aware of, although it return a bunch of data I need to use. It contains some fields with null values, while others are fully filled (note that the entire row is not null, only some fields) Well I'm using PDO and PHP on an Ubuntu 10.10 machine to get that information, my getReport method is:

public function getReport($empresa1, $empresa2, $num) {
    $ds = $this->connection->prepare('SP_REPORT_HOME ?,?,?');
    $ds->bindParam(1, $empresa1, PDO::PARAM_STR, 4);
    $ds->bindParam(2, $empresa2, PDO::PARAM_STR, 4);
    $ds->bindParam(3, $num, PDO::PARAM_INT, 4);
    $ds->execute(); 
    return $ds->fetchAll();
}

The $this->connection is just a PDO instance created like this:

$this->connection = new PDO(
        "dblib:host=IP:PORT;dbname=DBNAME", 
        "LOGIN", 
        "PASS"
    );

The method returns the array containing the data without the rows that contain null fields, anyone know why it doesn't show these rows? I really need them. I'm using PHP5.3 and SQLServer 2008

4

2 回答 2

0

查看http://php.net/manual/en/pdo.setattribute.php了解 ATTR_ORACLE_NULLS 设置。我猜调整此设置将获得您想要的输出。

于 2011-05-06T15:24:16.017 回答
0

好吧,最终程序出现了错误,尽管这确实很奇怪。

该过程在其中一个步骤中创建一个临时表并插入我想要的数据。在我们在这里使用的其他系统(内置 java)中,该过程运行良好,完全没有错误,所有数据都在那里。SQL Server Management Studio 也是如此,没有查询错误。

尽管在 php 中插入失败,因为它创建的表没有空字段(尽管没有说这样做)。我发现这个尝试使用 mssql 方式进行连接和查询。在 $connection->query() 调用中,它显示了一个插入错误,说我试图在一个非空字段中插入空值。虽然没有停止脚本。导致结果中没有包含空字段的行。pdo 版本可能有同样的问题,但抑制了错误消息。

好吧,我们更改了程序,因此表创建指示空字段,但是,我们仍然不知道为什么它在所有其他系统中都有效,并且在 php 中它为这些字段使用了另一个默认值......

于 2011-05-07T14:52:21.553 回答