Results 1 to 2 of 2

Thread: PDO Issue

  1. #1
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    486
    Thanks
    8
    Thanked 52 Times in 50 Posts

    Default PDO Issue

    So I am having a bit of problems and I am not entirely sure what is going on. Currently, I have something in my php code that allows me to insert a new type id.
    Code:
    try {
    			$this->db->connect()->getHandler()->beginTransaction();
    			$stmt = $this->db
    				->query("INSERT INTO tbl_TokenType (name) VALUES (?)")
    				->exe(array($name))
    				->getStatement();
    
    			if ( !$stmt ) {
    				throw new Exception('Failed to insert');
    			}
    			$this->db->getHandler()->commit();
    			$this->db->close();
    		} catch (Exception $e) {
    			$this->db->rollback();
    		}
    		return $this;
    Dont worry about the extra calls but that inserts correctly and creates the information.

    Now if I try to insert something larger eg:
    Code:
    try {
    			$this->db->connect()->getHandler()->beginTransaction();
    			$stmt = $this->db
    				->query("INSERT INTO tbl_Account (Active, Banned, Confirmed, Email, AccountLevel, MaxProfiles) VALUES (:Active, :Banned, :Confirmed, :Email, :AccountLevel, :MaxProfiles)")
    				->exe(array(
    					"Active" => 1,
    					"Banned" => 0,
    					"Confirmed" => 0, 
    					"Email" => $email,
    					"AccountLevel" => 1, 
    					"MaxProfiles" => 10
    				))
    				->getStatement();
    
    			if ( !$stmt ) {
    				throw new Exception('Failed to insert');
    			}
    			$this->db->getHandler()->commit();
    			$id = $this->db->getHandler()->lastInsertId();
    			$this->db->close();
    		} catch(Exception $e) {
    			$this->db->rollback();
    			$id = 0;
    			$message = $e->getMessage();
    		}
    If fails to insert for some unknown reason; however, it doesnt throw any issue in the catch. Not sure what is going on...
    Any ideas would be great. Oh another note the following code works directly from the db:
    Code:
    INSERT INTO tbl_Account (Active, Banned, Confirmed, Email, AccountLevel, MaxProfiles) VALUES (1,0,0,'someemail@yahoo.com',1,10)
    I am completely stumped
    Last edited by Deadweight; 02-20-2018 at 04:08 AM.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    486
    Thanks
    8
    Thanked 52 Times in 50 Posts

    Default

    Never I answered it myself, the issue was that i was using bit(1) instead of tinyint(1)
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

Similar Threads

  1. Replies: 3
    Last Post: 02-15-2011, 02:37 AM
  2. AnyLink Drop Down Menu - border issue *and* FF alignment issue
    By trjonas in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 12-18-2007, 05:58 AM
  3. Email issue -- Carbon Copy Issue
    By Humper in forum HTML
    Replies: 0
    Last Post: 09-01-2006, 09:01 PM
  4. Email issue -- Carbon Copy Issue
    By Humper in forum PHP
    Replies: 1
    Last Post: 09-01-2006, 08:47 PM
  5. Email issue -- Carbon Copy Issue
    By Humper in forum JavaScript
    Replies: 0
    Last Post: 09-01-2006, 07:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •