{"id":1268,"date":"2013-01-29T00:43:44","date_gmt":"2013-01-29T08:43:44","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=1268"},"modified":"2024-01-03T18:25:46","modified_gmt":"2024-01-04T01:25:46","slug":"php-mysql","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/php-mysql\/","title":{"rendered":"PHP MySQL Tutorial"},"content":{"rendered":"\n<p>In this section, you will learn how to interact with MySQL using the PHP Data Objects or PDO.<\/p>\n\n\n\n<p>The PDO is a data-access abstraction layer. PDO is a PHP extension that provides a lightweight and consistent interface for interacting with any database, including MySQL.<\/p>\n\n\n\n<p class=\"note\">This tutorial assumes that you have basic PHP knowledge. If you want to learn PHP, check out the <a href=\"https:\/\/www.phptutorial.net\/\" target=\"_blank\" rel=\"noreferrer noopener\">PHP tutorial<\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"654\" height=\"301\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/09\/php-mysql.png\" alt=\"php mysql\" class=\"wp-image-9076\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/09\/php-mysql.png 654w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/09\/php-mysql-200x92.png 200w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/figure>\n<\/div>\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Section 1. Connecting to MySQL<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-connecting-to-mysql-database\/\">Connecting to MySQL Database<\/a> &#8211; show you how to connect to a MySQL database server using the PDO object.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Section 2. Creating Tables<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a title=\"PHP MySQL: Create A New Table\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-mysql-create-table\/\">Creating a New Table<\/a> &#8211; show you step by step how to create a table in MySQL using PDO<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Section 3. Basic Operations: CRUD<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-querying-data-from-mysql-database\/\">Querying Data<\/a> &#8211; guide you on how to query data from MySQL database using PHP PDO and show you how to use PDO prepared statement to select data from a table.<\/li>\n\n\n\n<li><a title=\"PHP MySQL: Insert Data Into a Table\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-insert-data-into-mysql-table\/\">Inserting Data Into a Table<\/a> &#8211; show you how to use PHP to insert data into MySQL a table.<\/li>\n\n\n\n<li><a title=\"PHP MySQL: Update Data\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-mysql-update-data\/\">Updating Data<\/a> &#8211; show you how to update data in a MySQL table using a PHP PDO prepared statement.<\/li>\n\n\n\n<li><a title=\"PHP MySQL: Delete Data\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-mysql-delete\/\">Deleting Data<\/a> &#8211; learn how to delete data from the MySQL database table using PHP PDO.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Section 4. Calling Stored Procedures<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a title=\"PHP MySQL: Call MySQL Stored Procedures\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-calling-mysql-stored-procedures\/\">Calling MySQL Stored Procedures<\/a> &#8211; show you how to call MySQL stored procedures using PHP PDO. It guides you on how to call stored procedures that return result sets and stored procedures that accept input\/output parameters.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Section 5. Managing Transactions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a title=\"PHP MySQL Transaction\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-mysql-transaction\/\">Dealing with transactions<\/a> &#8211; show you how to handle MySQL transactions in PHP to ensure the data integrity of databases.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Section 6. Working with BLOB<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/php-mysql-blob\/\">Manipulating BLOB<\/a> &#8211; show you how to handle BLOB data using PDO, including inserting, updating, and selecting BLOB data from the MySQL database.<\/li>\n<\/ul>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>You will learn how to interact with MySQL using PHP Data Objects or PDO, which provides a lightweight and consistent interface for accessing MySQL Database.<\/p>\n","protected":false},"author":2,"featured_media":10054,"parent":0,"menu_order":23,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1268","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP MySQL Tutorial<\/title>\n<meta name=\"description\" content=\"PHP Data Objects or PDO provides you with a lightweight and consistent interface for accessing MySQL databases. And this tutorial shows you how how to interact with MySQL using PDO.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/php-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP MySQL Tutorial\" \/>\n<meta property=\"og:description\" content=\"PHP Data Objects or PDO provides you with a lightweight and consistent interface for accessing MySQL databases. And this tutorial shows you how how to interact with MySQL using PDO.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/php-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-04T01:25:46+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/\",\"name\":\"PHP MySQL Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-php.svg\",\"datePublished\":\"2013-01-29T08:43:44+00:00\",\"dateModified\":\"2024-01-04T01:25:46+00:00\",\"description\":\"PHP Data Objects or PDO provides you with a lightweight and consistent interface for accessing MySQL databases. And this tutorial shows you how how to interact with MySQL using PDO.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-php.svg\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-php.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/php-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP MySQL Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP MySQL Tutorial","description":"PHP Data Objects or PDO provides you with a lightweight and consistent interface for accessing MySQL databases. And this tutorial shows you how how to interact with MySQL using PDO.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/php-mysql\/","og_locale":"en_US","og_type":"article","og_title":"PHP MySQL Tutorial","og_description":"PHP Data Objects or PDO provides you with a lightweight and consistent interface for accessing MySQL databases. And this tutorial shows you how how to interact with MySQL using PDO.","og_url":"https:\/\/www.mysqltutorial.org\/php-mysql\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-04T01:25:46+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/php-mysql\/","url":"https:\/\/www.mysqltutorial.org\/php-mysql\/","name":"PHP MySQL Tutorial","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/php-mysql\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/php-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-php.svg","datePublished":"2013-01-29T08:43:44+00:00","dateModified":"2024-01-04T01:25:46+00:00","description":"PHP Data Objects or PDO provides you with a lightweight and consistent interface for accessing MySQL databases. And this tutorial shows you how how to interact with MySQL using PDO.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/php-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/php-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/php-mysql\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-php.svg","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-php.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/php-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"PHP MySQL Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/1268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=1268"}],"version-history":[{"count":5,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/1268\/revisions"}],"predecessor-version":[{"id":14057,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/1268\/revisions\/14057"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media\/10054"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=1268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}