Home » Database » DB » Bug #4801
query ,wtih one recordset
Details
| Submitted | 2005-07-12 08:37 UTC |
|---|---|
| From | gregory dot scotti at abyss-land dot com |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 5.0.4 |
| OS | Linux web103.720.ha.ovh.net 2.4. |
| Roadmaps | (Not assigned) |
Comments
[2005-07-12 08:37 UTC] gregory dot scotti at abyss-land dot com
Description:
------------
Bonjour , je vais essaie de m'exprimer en anglais
I have a probleme whith the methode
getAssoc($sql), query($sql) , if the query look like
select count(*) from membre where mail = 'mail@domain.tdt'
Reproduce code:
---------------
$dsn = new dns();
$db =& DB::connect($dsn->getDns(), $options);
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$sql = 'SELECT idMembre as id, idMembre, nom from membre LIMIT 0 , 1;' ;
$rs = $db->getAssoc($sql) ;
debug ( $db->last_query , '$db->last_query ' );
debug ($rs, '$rs' ) ;
$sql = "SELECT count( * ) as count
FROM membre where mail = '%' " ;
$rs = $db->getAll($sql) ;
debug ( $db->last_query , '$db->last_query ' );
debug ($rs, '$rs' ) ;
$sql = "SELECT count( * ) as count
FROM membre where mail = '%' " ;
$rs = $db->getAssoc($sql) ;
debug ( $db->last_query , '$db->last_query ' );
debug ($rs, '$rs' ) ;
$sql = "SELECT count( * ) as count
FROM membre where mail = '%' " ;
$rs = $db->query($sql) ;
debug ( $db->last_query , '$db->last_query ' );
debug ($rs, 'THIRD QUERY $db->query($sql)' ) ;
Expected result:
----------------
I expected to not have SQL error :-) I just used another methode to get the result.
When i read the documentation i don't find an explication of this behavior.
Actual result:
--------------
$db->last_query
SELECT idMembre as id, idMembre, nom from membre LIMIT 0 , 1;
FIRST QUERY $db->getAssoc($sql)
Array
(
[3] => Array
(
[idMembre] => 3
[nom] => nom
)
)
$db->last_query
SELECT count( * ) as count
FROM membre where mail = '%'
SECOND QUERY $db->getAll($sql)
Array
(
[0] => Array
(
[count] => 0
)
)
$db->last_query
SELECT count( * ) as count
FROM membre where mail = '%'
THIRD QUERY $db->getAssoc($sql)
DB_Error Object
((
[error_message_prefix] =>
[mode] => 1
[level] => 1024
[code] => -10
[message] => DB Error: truncated
[userinfo] => SELECT count( * ) as count
FROM membre where mail = '%' [DB Error: truncated]
[backtrace] => Array
(
[0] => Array
(
[file] => /home/arobazcr/www/pear2/DB.php
[line] => 888
[function] => PEAR_Error
[class] => DB_Error
[type] => ->
[args] => Array
(
[0] => DB Error: truncated
[1] => -10
[2] => 1
[3] => 1024
[4] => SELECT count( * ) as count
FROM membre where mail = '%' [DB Error: truncated]
)
)
[1] => Array
...
...
[2005-07-14 13:15 UTC] gregory dot scotti at abyss-land dot com
Now it's not a slq syntaxe i tried all my query y a query analyser like phpmyadmin. It's a lake in the documentation ou a DB error.
The second query and third query are the same, but le getAssoc() throw an error, in the third case.
Cordialement Gregory