From:             face at dfhu dot org
Operating system: Ubuntu
PHP version:      5.3.0
PHP Bug Type:     SQLite related
Bug description:  PDO::Execute and SQLite CHECK constarints quoting INTS

Description:
------------
PDO::Execute quotes integers even though this will cause problems in
SQLite. SQLite has type affinity and sometimes requires hard checks.

that is "(product_id) VALUES ('1')" is NOT the same as "(product_id)
VALUES (1)";


Thanks!
 -- Victory 
http://dfhu.org/blog/


Reproduce code:
---------------
$pdo=new PDO("sqlite:./db/sales.sqlite");
$pdo->setAttribute(PDO::ATTR_ERRMODE,
                   PDO::ERRMODE_EXCEPTION);
$sql="
CREATE TABLE IF NOT EXISTS sales (
product_id INT
 CHECK(typeof(product_id) = 'integer')
)";
$pdo->query($sql);

$sql="
INSERT INTO sales
 (product_id)
   VALUES
 (:product_id)";
$statement=$pdo->prepare($sql);

// this will throw a integrity constraint error
$statement->execute(Array(":product_id"=>1));


Expected result:
----------------
I do not expect to see an exception thrown, i expect PDO::execute() to not
quote integers in SQLite. Thus there should be no output.

Actual result:
--------------
Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity
constraint violation: 19 constraint failed'

-- 
Edit bug report at http://bugs.php.net/?id=49268&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49268&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49268&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49268&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49268&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49268&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49268&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49268&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49268&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49268&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49268&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49268&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49268&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49268&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49268&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49268&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49268&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49268&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49268&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49268&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49268&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49268&r=mysqlcfg

Reply via email to