{"id":70061,"date":"2021-08-24T04:10:07","date_gmt":"2021-08-24T08:10:07","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/database-operation-handling-in-php-16\/"},"modified":"2021-08-24T04:10:07","modified_gmt":"2021-08-24T08:10:07","slug":"database-operation-handling-in-php-16","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=70061","title":{"rendered":"Database Operation Handling in PHP #16"},"content":{"rendered":"<pre style=\"padding-left: 5px\">Not the best approach. Just one approach. At least to help with thinking. to start with.\n\n&lt; ?php       \n\n\/\/you can keep database parameters in a file [text file or xml file]. \n\n\/*\nCreate two users one with only read permission, another with read-write permission. \nUse read user related connection in read only operations. \nread-write user related database connection should be used only when writing is associated\n*\/\n\n\/\/database user with read only permission   \n$roUser = \"\";   \n$roPassword = \"\";   \n\n\/\/database user with read-write permission      \n$rwUser = \"\";   \n$rwPassword = \"\";           \n\n\/\/database and the host $host = \"localhost\";    \n$database = \"your_database\";    \n\n?&gt;\n\n&lt; ?php            \n\n\/\/read only handle to database  \n$dbhReadOnly = null;         \n\n\/\/read-write handle to database \n$dbhReadWrite = null;   \n\n\/\/read-write connection creation    \nfunction getDbhReadWrite(){         \n\nglobal $rwUser, $rwPassword, $host, $database;              \n\/\/connect to db with user that has read-write permission to the database        $dbhReadWrite = mysqli_connect( \"$host\",  \"$rwUser\", \"$rwPassword\", \"$database\");       \/\/var_dump($dbhReadWrite);              \nif (!($dbhReadWrite))           \nreturn null;                \nreturn  $dbhReadWrite;          \n\n}   \n\n\/\/read-only connection creation \nfunction getDbhReadOnly(){          \nglobal $roUser, $roPassword, $host, $database;              \n\n\/\/connect to the database with a user that has only read permission to the database     \n\n$dbhReadOnly = mysqli_connect( \"$host\",  \"$roUser\", \"$roPassword\", \"$database\");                        \n\nif (!($dbhReadOnly))            \nreturn null;                \nreturn  $dbhReadOnly;           \n}       \n\n\/\/read-only connection - can be used from other php files    \n$dbhReadWrite = getDbhReadWrite();\n\n\/\/read-write connection-     \n$dbhReadOnly = getDbhReadOnly();\n\n?&gt;<\/pre>\n<p>From: http:\/\/sitestree.com\/?p=5135<br \/> Categories:16<br \/>Tags:<br \/> Post Data:2007-01-01 17:15:46<\/p>\n<pre><code>    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\"&gt;https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    (Big Data, Cloud, Security, Machine Learning): Courses: &lt;a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"&gt; http:\/\/Training.SitesTree.com&lt;\/a&gt; \n    In Bengali: &lt;a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\"&gt;http:\/\/Bangla.SaLearningSchool.com&lt;\/a&gt;\n    &lt;a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\"&gt;http:\/\/SitesTree.com&lt;\/a&gt;\n    8112223 Canada Inc.\/JustEtc: &lt;a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\"&gt;http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) &lt;\/a&gt;\n    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com'&gt; https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    Medium: &lt;a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"&gt; https:\/\/medium.com\/@SayedAhmedCanada &lt;\/a&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Not the best approach. Just one approach. At least to help with thinking. to start with. &lt; ?php \/\/you can keep database parameters in a file [text file or xml file]. \/* Create two users one with only read permission, another with read-write permission. Use read user related connection in read only operations. read-write user &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=70061\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-70061","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":6085,"url":"http:\/\/bangla.sitestree.com\/?p=6085","url_meta":{"origin":70061,"position":0},"title":"\u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf : \u098f\u0995\u099f\u09bf \u09ae\u09be\u0987\u098f\u09b8\u0995\u09bf\u0989\u098f\u09b2 \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u09a4\u09c8\u09b0\u09bf \u0995\u09b0\u09be (PHP Create a MySQL Database)","author":"Author-Check- Article-or-Video","date":"February 24, 2015","format":false,"excerpt":"Sheikh Mahfuzur Rahman \u00a0 \u098f\u0995\u099f\u09bf \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u098f\u0995 \u09ac\u09be \u09a4\u09be\u09b0\u0993 \u09ac\u09c7\u09b6\u09bf \u099f\u09c7\u09ac\u09b2 \u09a8\u09bf\u09df\u09c7 \u0997\u09a0\u09bf\u09a4\u0964 \u0995\u09cb\u09a8 MySQL \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u09a4\u09c8\u09b0\u09bf \u09ac\u09be \u09ae\u09c1\u0981\u099b\u09c7 \u09a6\u09bf\u09a4\u09c7 \u099a\u09be\u0987\u09b2\u09c7 \u0986\u09aa\u09a8\u09be\u09b0 \u09ac\u09bf\u09b6\u09c7\u09b7 \u09a7\u09b0\u09a3\u09c7\u09b0 \u0986\u0987\u09a8\u0997\u09a4 \u0985\u09a7\u09bf\u0995\u09be\u09b0 \u09b2\u09be\u0997\u09ac\u09c7 \u09af\u09be CREATE \u09a8\u09be\u09ae\u09c7 \u09aa\u09b0\u09bf\u099a\u09bf\u09a4\u0964 MySQLi \u098f\u09ac\u0982 PDO \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 \u0995\u09b0\u09c7 \u098f\u0995\u099f\u09bf \u09ae\u09be\u0987\u098f\u09b8\u0995\u09bf\u0989\u098f\u09b2 \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u09a4\u09c8\u09b0\u09bf \u0995\u09b0\u09be CREATE DATABASE \u09b8\u09cd\u099f\u09c7\u099f\u09ae\u09c7\u09a8\u09cd\u099f \u09ae\u09be\u0987\u098f\u09b8\u0995\u09bf\u0989\u098f\u09b2-\u098f \u098f\u0995\u099f\u09bf \u09a1\u09be\u099f\u09be\u09ac\u09c7\u099c \u09a4\u09c8\u09b0\u09bf \u0995\u09b0\u09a4\u09c7 \u09ac\u09cd\u09af\u09ac\u09b9\u09c3\u09a4\u2026","rel":"","context":"In &quot;\u09aa\u09bf \u098f\u0987\u099a \u09aa\u09bf \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 PHP tutorial&quot;","block_context":{"text":"\u09aa\u09bf \u098f\u0987\u099a \u09aa\u09bf \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 \u0964 PHP tutorial","link":"http:\/\/bangla.sitestree.com\/?cat=172"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7005,"url":"http:\/\/bangla.sitestree.com\/?p=7005","url_meta":{"origin":70061,"position":1},"title":"MongoDB PHP. MongoDB \u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf","author":"Author-Check- Article-or-Video","date":"April 24, 2015","format":false,"excerpt":"MongoDB \u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf \u09a8\u09df\u09a8 \u099a\u09a8\u09cd\u09a6\u09cd\u09b0 \u09a6\u09a4\u09cd\u09a4 \u00a0 \u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf \u098f\u09b0 \u09b8\u0999\u09cd\u0997\u09c7 MongoDB \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 \u0995\u09b0\u09be\u09b0 \u099c\u09a8\u09cd\u09af \u0986\u09aa\u09a8\u09be\u0995\u09c7 MongoDB \u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf \u09a1\u09cd\u09b0\u09be\u0987\u09ad\u09be\u09b0 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 \u0995\u09b0\u09a4\u09c7 \u09b9\u09ac\u09c7\u0964 \u09a8\u09bf\u099a\u09c7\u09b0 \u09b2\u09bf\u0999\u09cd\u0995 \u09a5\u09c7\u0995\u09c7 \u09a1\u09cd\u09b0\u09be\u0987\u09ad\u09be\u09b0\u099f\u09bf \u09a1\u09be\u0989\u09a8\u09b2\u09cb\u09a1 \u0995\u09b0\u09c7 \u09a8\u09bf\u09a8\u0983 https:\/\/s3.amazonaws.com\/drivers.mongodb.org\/php\/index.html \u09b8\u09b0\u09cd\u09ac\u09b6\u09c7\u09b7 \u09b0\u09bf\u09b2\u09bf\u099c \u09a1\u09be\u0989\u09a8\u09b2\u09cb\u09a1 \u0995\u09b0\u09a4\u09c7 \u09ad\u09c1\u09b2\u09ac\u09c7\u09a8 \u09a8\u09be\u0964 \u098f\u0996\u09a8 \u0986\u09b0\u09cd\u0995\u09be\u0987\u09ad\u099f\u09bf \u0986\u09a8\u099c\u09bf\u09aa \u0995\u09b0\u09c1\u09a8 \u098f\u09ac\u0982 \u0986\u09aa\u09a8\u09be\u09b0 \u09aa\u09bf\u098f\u0987\u099a\u09aa\u09bf \u098f\u0995\u09cd\u09b8\u099f\u09c7\u09a8\u09b6\u09a8 \u09a1\u09bf\u09b0\u09c7\u0995\u09cd\u099f\u09b0\u09bf\u09b0 (\"ext\" \u09a1\u09bf\u09ab\u09b2\u09cd\u099f\u09ad\u09be\u09ac\u09c7) \u09ae\u09a7\u09cd\u09af\u09c7 php_mongo.dll \u098f \u098f\u09ac\u0982 \u09a8\u09bf\u099a\u09c7\u09b0\u2026","rel":"","context":"In &quot;\u09ae\u0999\u09cd\u0997 \u09a1\u09bf \u09ac\u09bf \u0964 MongoDB&quot;","block_context":{"text":"\u09ae\u0999\u09cd\u0997 \u09a1\u09bf \u09ac\u09bf \u0964 MongoDB","link":"http:\/\/bangla.sitestree.com\/?cat=222"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67452,"url":"http:\/\/bangla.sitestree.com\/?p=67452","url_meta":{"origin":70061,"position":2},"title":"iBATIS: Some Notes #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 22, 2021","format":false,"excerpt":"You can download iBatis library from http:\/\/ibatis.apache.org\/. Just make the Jar files available to your application iBatis with Spring: Need to configure at least three files. Spring config file (applicationContext.xml) - Define database connection parameters, the location of the SQL Map config file, and one or more Spring beans for\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":68483,"url":"http:\/\/bangla.sitestree.com\/?p=68483","url_meta":{"origin":70061,"position":3},"title":"Access 2007: How to #90","author":"Author-Check- Article-or-Video","date":"August 4, 2021","format":false,"excerpt":"Access 2007: How toHow to compact and repair database?File menu (Alt+F) -> Manage -> Compact and Repair Database. Why? To reduce file\/database size. Helpful - when you want to upload to a remote server. Compacting and Repairing databases many times can solve many database issues. Use the feature once in\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10113,"url":"http:\/\/bangla.sitestree.com\/?p=10113","url_meta":{"origin":70061,"position":4},"title":"DatabaseUtilities.java: Several general-purpose utilities discussed and used in the chapter.","author":"","date":"August 4, 2015","format":false,"excerpt":"package cwp; import java.sql.*; \/** Three database utilities: \u00a0*\u00a0\u00a0 1) getQueryResults. Connects to a database, executes \u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0 a query, retrieves all the rows as arrays \u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0 of strings, and puts them inside a DBResults \u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0 object. Also places the database product name, \u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0 database version, and the names of all\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69123,"url":"http:\/\/bangla.sitestree.com\/?p=69123","url_meta":{"origin":70061,"position":5},"title":"Hibernate: A simple example #48","author":"Author-Check- Article-or-Video","date":"August 12, 2021","format":false,"excerpt":"Hibernate: A simple example First, you need to create an xml file to specify the database parameters that you are going to use. Database parameters may include: the database driver, user name and password to access the database. Then you should create a persistent class to represent the database table.\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70061"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70061\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70061"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}