Hi.

The code I use to extract the data from a query which was just
performed looks like this:

                $data = array();
                $receiverRow = array();
                $i = 0;
                foreach ($columns as $column => $type)
                        $statement->bindColumn($i++, &$receiverRow[$column], 
$type);
                while ($statement->fetch(PDO::FETCH_BOUND))
                {
                        $row = array();
                        foreach ($columns as $column => $type)
                                $row[$column] = $receiverRow[$column];
                        $data[] = $row;
                }


I know there is a record that fetch should fetch, since $statement->
rowCount() says so. Everything works really well, and even if I check
$statement->errorInfo() and $statement->errorCode() after each
operation with the database, I can see no error. The types with which
the variables are bound are also right.

However, the $statement->fetch() inside the the while statement
returns false at the very first call, so I can't fetch anything from
within the $statement. There is no exception, no non-zero value in
$statement->errorInfo(), and $statement->errorCode() says
uninitialized. So I don't know what actually went wrong.

The entire process happens inside a transaction. At the end, finding
out that the record was not retrieved, the transaction is rolled back.

The statement is an insert following by a select. When calling
PDO::lastInsertId, I get a proper value, which means the insert is
succesful. When checking $statement->rowCount() I also get a count of
1, which means the select also worked properly. I just fail to fetch
the just inserted record into some PHP variables.

What am I doing wrong? As far as I can tell, I did everything as the
manual says.

br,

-- 
Fine counsel is confusing, but example is always clear. (Edgar A.
Guest, The Light of Faith)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to