neogranas Posted February 21, 2011 Share Posted February 21, 2011 I'm hoping to get direction on this subject. I've seen some articles and how-to's on PDO recently and all I've ever seen on them is seemingly just an alternative to use mysql_(whatever). Can someone explain to me what the difference between them is and why one would be better than the other, or if it's just a situation of use PDO when doing one sort of application and mysql_(whatever) for another? I did search the forums and didn't find anything that really explained it to me, but maybe I didn't search right, if I missed where this has already been brought up, I apologize. Link to comment https://forums.phpfreaks.com/topic/228351-pdo-vs-mysql_/ Share on other sites More sharing options...
ali_kiyani Posted February 21, 2011 Share Posted February 21, 2011 1. With PDO you don't need to write separate code when you change database. mysql_connect will only work for MySQL and not MS SQL Server or Oracle. For that you will need to use different methods. PDO solve this problem. 2. With PDO when you use parameters then all user input is automatically sanitized. You don't need to sanitize it. Link to comment https://forums.phpfreaks.com/topic/228351-pdo-vs-mysql_/#findComment-1177522 Share on other sites More sharing options...
neogranas Posted February 22, 2011 Author Share Posted February 22, 2011 Is there any advantages to using PDO such as execution time or security? The reason I'm asking is because I've just started building an application and I would like to know if I could just continue with what I know using mysql_connect or if I should switch. Any advice? Link to comment https://forums.phpfreaks.com/topic/228351-pdo-vs-mysql_/#findComment-1178198 Share on other sites More sharing options...
ali_kiyani Posted February 22, 2011 Share Posted February 22, 2011 Yes you should use it. No idea about execution time but it is secure and the second point I posted above deals with it. Here is a very nice tutorial on what is PDO and how to use it. http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html Link to comment https://forums.phpfreaks.com/topic/228351-pdo-vs-mysql_/#findComment-1178218 Share on other sites More sharing options...
neogranas Posted February 22, 2011 Author Share Posted February 22, 2011 Excellent, thank you very much. Link to comment https://forums.phpfreaks.com/topic/228351-pdo-vs-mysql_/#findComment-1178230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.