Home » Database » DB » Bug #792
? in query with sybse and db->query doesnt work
Details
| Submitted | 2004-02-18 21:54 UTC |
|---|---|
| From | konrek at gmx dot net |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 4.3.4 |
| OS | linux |
| Roadmaps | (Not assigned) |
Comments
[2004-02-18 21:54 UTC] konrek at gmx dot net
Description:
------------
trying to execute a implizit parameter-query with $dbc->query( $sql, $var ) doesnt work with sybase
Reproduce code:
---------------
class DCGenerator
{
var $format = DC_FORMAT_HTML;
var $dbc; // dbConnection
var $allTypeDCQuery = "select DC.Element_Name as name, DC.Element_Schema as sheme, DC.Meta_Table as metatable, DC.Query as query from Type T, DC_for_Type R, DC_Element as DC where T.Type_ID= ? and T.Type_ID=R.Type_ID and R.Element_ID=DC.Element_ID";
/****************************************
*
* @public
* @param mixed $type string oder int
* @param int $resource id - der Resource
* @return string mit allen tags
****************************************/
function getAll( $type , $resource)
{
//db-Zugriff und dann alle Elemente rausholen, die vorhanden
$result =& $this->dbc->query( $this->allTypeDCQuery, (integer)$type );
echo "<br /> ";print_r( $result );
if ( DB::isError( $result ) ) {
die ( $result->getMessage() );
}
}// end function
Expected result:
----------------
should execute query bie replacing parameter
Actual result:
--------------
db_error Object ( [error_message_prefix] => [mode] => 1 [level] => 1024 [code] => 257 [message] => DB Error: unknown error [userinfo] => Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query. [nativecode=-11] [backtrace] => Array ( [0] => Array ( [file] => /usr/local/php-4.3.4/lib/php/DB.php [line] => 642 [function] => pear_error [class] => db_error [type] => -> [args] => Array ( [0] => DB Error: unknown error [1] => 257 [2] => 1 [3] => 1024 [4] => Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query. [nativecode=-11] ) ) [1] => Array ( [file] => /usr/local/php-4.3.4/lib/php/PEAR.php [line] => 525 [function] => db_error [class] => db_error [type] => -> [args] => Array ( [0] => 257 [1] => 1 [2] => 1024 [3] => Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query. [nativecode=-11] ) ) [2] => Array ( [file] => /usr/local/php-4.3.4/lib/php/DB/common.php [line] => 298 [function] => raiseerror [class] => pear [type] => :: [args] => Array ( [0] => [1] => 257 [2] => [3] => [4] => Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query. [nativecode=-11] [5] => DB_Error [6] => 1 ) ) [3] => Array ( [file] => /usr/local/php-4.3.4/lib/php/DB/sybase.php [line] => 199 [function] => raiseerror [class] => db_sybase [type] => -> [args] => Array ( [0] => 257 [1] => [2] => [3] => Implicit conversion from datatype 'VARCHAR' to 'SMALLINT' is not allowed. Use the CONVERT function to run this query. [4] => -11 ) ) [4] => Array ( [file] => /usr/local/php-4.3.4/lib/php/DB/sybase.php [line] => 235 [function] => sybaseraiseerror [class] => db_sybase [type] => -> [args] => Array ( ) ) [5] => Array ( [file] => /usr/local/php-4.3.4/lib/php/DB/common.php [line] => 563 [function] => simplequery [class] => db_sybase [type] => -> [args] => Array ( [0] => select DC.Element_Name as name, DC.Element_Schema as sheme, DC.Meta_Table as metatable, DC.Query as query from Type T, DC_for_Type R, DC_Element as DC where T.Type_ID= '122' and T.Type_ID=R.Type_ID and R.Element_ID=DC.Element_ID ) ) [6] => Array ( [file] => /usr/local/php-4.3.4/lib/php/DB/common.php [line] => 758 [function] => execute [class] => db_sybase [type] => -> [args] => Array ( [0] => 0 [1] => 122 ) ) [7] => Array ( [file] => /usr/local/www/htdocs/docserv/browsing/scripts/MetaOut/dc/DCGenerator.class.php [line] => 46 [function] => query [class] => db_sybase [type] => -> [args] => Array ( [0] => select DC.Element_Name as name, DC.Element_Schema as sheme, DC.Meta_Table as metatable, DC.Query as query from Type T, DC_for_Type R, DC_Element as DC where T.Type_ID= ? and T.Type_ID=R.Type_ID and R.Element_ID=DC.Element_ID [1] => 122 ) ) [8] => Array ( [file] => /usr/local/www/htdocs/docserv/browsing/scripts/MetaOut/dc/DCGenerator.class.php [line] => 119 [function] => getall [class] => dcgenerator [type] => -> [args] => Array ( [0] => 122 [1] => 20221 ) ) ) [callback] => ) DB Error: unknown error
[2007-02-10 20:42 UTC] juanchw at yahoo dot com
problem is when the Sybase makes the query if you send an int value, the PEAR put quotes in int variables. then the sybase get an error about conversion from var to int.
if you put where id = 1 the Pea::DB will do this. id = '1' sybase sends error. should be without quotes