Home » Database » MDB2 » Bug #7171
UpdateQueryResult->numRows() returns mdb2_error Object when query executed
Details
| Submitted | 2006-03-21 10:42 UTC |
|---|---|
| From | jorglez at gmail dot com |
| Status | Bogus |
| Package | MDB2 |
| PHP Version | Irrelevant |
| OS | WinXP |
| Roadmaps | (Not assigned) |
Comments
[2006-03-21 10:42 UTC] jorglez at gmail dot com
Description:
------------
$sql = 'UPDATE '.$this->table.' SET
prints=prints+1
WHERE section="'.$section.'"
AND subsection="'.$subsection.'"
AND period="'.$period.'"
AND val='.$val;
$r = $this->db->query($sql);
then $r->numRows() will return an mdb2_error Object, no matter the table has been updated or not.
(Working with MySQL)
Test script:
---------------
//Working with MySQL
$sql = 'UPDATE '.$this->table.' SET
prints=prints+1
WHERE section="'.$section.'"
AND subsection="'.$subsection.'"
AND period="'.$interval.'"
AND val='.$val;
$r = $this->db->query($sql);
echo $sql.'<br/>';
echo '<pre>'; print_r($r->numRows()); echo '</pre>';
Expected result:
----------------
The number of updated rows, 0 if none
Actual result:
--------------
print_r of $r->numRows() (independant if the table has been updated or not)
mdb2_error Object
(
[error_message_prefix] =>
[mode] => 1
[level] => 1024
[code] =>
[message] => MDB2 Error: unknown error
[userinfo] => [Last query: UPDATE stats SET
prints=prints+1
WHERE section="forum"
AND subsection="view"
AND period="anio"
AND val=2006]
[Native code: 0]
[Native message: ]
[backtrace] => Array
(
[0] => Array
(
[file] => d:\_prog\code\php\pear\MDB2.php
[line] => 866
[function] => pear_error
[class] => mdb2_error
[type] => ->
[args] => Array
(
[0] => MDB2 Error: unknown error
[1] =>
[2] => 1
[3] => 1024
[4] => [Last query: UPDATE stats SET
prints=prints+1
WHERE section="forum"
AND subsection="view"
AND period="anio"
AND val=2006]
[Native code: 0]
[Native message: ]
)
)
[1] => Array
(
[file] => d:\_prog\code\php\pear\PEAR.php
[line] => 557
[function] => mdb2_error
[class] => mdb2_error
[type] => ->
[args] => Array
(
[0] =>
[1] => 1
[2] => 1024
[3] => [Last query: UPDATE stats SET
prints=prints+1
WHERE section="forum"
AND subsection="view"
AND period="anio"
AND val=2006]
[Native code: 0]
[Native message: ]
)
)
[2] => Array
(
[file] => d:\_prog\code\php\pear\MDB2.php
[line] => 1230
[function] => raiseerror
[class] => pear
[type] => ::
[args] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] => [Last query: UPDATE stats SET
prints=prints+1
WHERE section="forum"
AND subsection="view"
AND period="anio"
AND val=2006]
[Native code: 0]
[Native message: ]
[5] => MDB2_Error
[6] => 1
)
)
[3] => Array
(
[file] => d:\_prog\code\php\pear\MDB2\Driver\mysql.php
[line] => 1002
[function] => raiseerror
[class] => mdb2_driver_mysql
[type] => ->
[args] => Array
(
)
)
[4] => Array
(
[file] => G:\wwwpub\work!\eNgine\sharedObjects\stats.php
[line] => 45
[function] => numrows
[class] => mdb2_bufferedresult_mysql
[type] => ->
[args] => Array
(
)
)
[5] => Array
(
[file] => G:\wwwpub\work!\eNgine_demo\public_html\index.php
[line] => 24
[function] => register
[class] => stats
[type] => ->
[args] => Array
(
[0] => forum
[1] => view
)
)
)
[callback] =>
)