0
    $query = '  Declare @MemCode Varchar(12);
                Declare @ConCounter decimal(28,0);
                Set @MemCode = null;
                Set @ConCounter = null; 

                EXECUTE spQMInsEventMember_TMS 
                "'.$masterEventCode.'",
                "'.$eventCode.'",
                '.$memberContactTitle.',
                "'.$guestFirstName.'",
                "'.$guestLastName.'",
                '.$address.',
                '.$townDescription.',
                '.$countryCode.',
                '.$postZip.',
                '.$STD.',
                '.$phone.',
                "'.$guestEmail.'",
                '.$isMember.',
                '.$divisionCode.',
                '.$statusCode.',
                '.$subStatusCode.',
                '.$memberTypeCode.',
                '.$memberTitles.',
                '.$memberSubType.',
                '.$classCode.',
                '.$subClassCode.',@MemCode OUTPUT,@ConCounter OUTPUT;
                SELECT @MemCode AS member_code, @ConCounter AS contact_counter;';
    //print_r($query);

    $res = $this->dbh->query($query);
print_r $res;

输出:

object(stdClass)#1 (2) { ["RESULT"]=> string(2) "OK" ["CONTACTCOUNTER"]=> object(stdClass)#2 (1) { ["queryString"]=> string(522) " Declare @MemCode Varchar(12); Declare @ConCounter decimal(28,0); Set @MemCode = null; Set @ConCounter = null; EXECUTE spQMInsEventMember_TMS "AC", "LAC1112", NULL, "Fred", "Smith", NULL, NULL, NULL, NULL, NULL, NULL, "b@b.com", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,@MemCode OUTPUT,@ConCounter OUTPUT; SELECT @MemCode AS member_code, @ConCounter AS contact_counter;" } } 
4

1 回答 1

0

查询返回一个 PDOStatement 对象,而不是结果数组。

要一次获得所有结果,请尝试:

$sth = $this->dbh->query($query);

if(!$sth)
{
    // Query failed. Find out Why
    $error = sth->errorInfo();
    print_r $error;
}
else
{
    // We got results.
    $res = sth->fetchAll();
    print_r $res;
}
于 2012-10-15T10:58:44.563 回答