PDA

View Full Version : Resolved PDO Issue



Deadweight
02-20-2018, 01:40 AM
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.


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:


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:


INSERT INTO tbl_Account (Active, Banned, Confirmed, Email, AccountLevel, MaxProfiles) VALUES (1,0,0,'someemail@yahoo.com',1,10)


I am completely stumped

Deadweight
02-20-2018, 04:08 AM
Never I answered it myself, the issue was that i was using bit(1) instead of tinyint(1)