Using a class for a connection with a MYSQL DB
Posted: Mon Jun 21, 2010 7:37 pm
First of all hello to everybody.
This is my first post here on the forum. I always looked around the forums and sites for questions I had, but I never joined a community. Well, my time has come, and I hope to get helped, and help anyone who needs a hand.
My thing is that I am starting a project. I was discussing with the other programmer involved in the project which type of connection to use with MYSQL. We were thinking about creating our own class, the mysqli class, and the pdo class. We choose the pdo. But please fell free to comment about the pros and cons of those options. Anyway, we found that in the pdo class exists three functions to handle errors. the beginTransaction() commit() and rollback(). I look at the php.net documentation, and tried a few different codes and saw that if I use the beginTransaction() and don't use the commit() the SQL code is not saved in the database.
My question is, how can I use those 3 functions to make sure if a query is run at the server, and any error happens during the process, no data is loss. Maybe a try catch?
This is the class I am using it to create the PDO object --> http://www.phpclasses.org/package/2855- ... l#download
This is my first post here on the forum. I always looked around the forums and sites for questions I had, but I never joined a community. Well, my time has come, and I hope to get helped, and help anyone who needs a hand.
My thing is that I am starting a project. I was discussing with the other programmer involved in the project which type of connection to use with MYSQL. We were thinking about creating our own class, the mysqli class, and the pdo class. We choose the pdo. But please fell free to comment about the pros and cons of those options. Anyway, we found that in the pdo class exists three functions to handle errors. the beginTransaction() commit() and rollback(). I look at the php.net documentation, and tried a few different codes and saw that if I use the beginTransaction() and don't use the commit() the SQL code is not saved in the database.
My question is, how can I use those 3 functions to make sure if a query is run at the server, and any error happens during the process, no data is loss. Maybe a try catch?
This is the class I am using it to create the PDO object --> http://www.phpclasses.org/package/2855- ... l#download