{"flag":true,"single":true,"pageTitle":"get_meta, set_meta custom in MYSQL , PHP","post":{"id":322,"user_id":"1","slug":"get-meta-set-meta-custom-in-mysql-php-yrem","title":"get_meta, set_meta custom in MYSQL , PHP","body":"<p>1. CREATE TABLE USING MYSQL<\/p>\r\n<pre class=\"language-markup\"><code>DROP TABLE IF EXISTS `options`;\r\nCREATE TABLE `options` (\r\n  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n  `metakey` varchar(255) NOT NULL,\r\n  `metavalue` varchar(255) NOT NULL,\r\n  `metaupdated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),\r\n  PRIMARY KEY (`id`)\r\n);\r\n<\/code><\/pre>\r\n<p>2. ADD FUNCTION TO CLASS<\/p>\r\n<pre class=\"language-markup\"><code>public function getMeta( $metakey )  {\r\n\t\t\t$sql=\"SELECT * from options where metakey='$metakey'\";\r\n\t\t\t$result=$this-&gt;conn-&gt;query($sql);\r\n\t\t\tif($result-&gt;num_rows&gt;0){\r\n\t\t\t\t$row = $result-&gt;fetch_assoc();\t\t\t\t\r\n\t\t\t}else{\r\n\t\t\t\t$row=false;\r\n\t\t\t}\r\n\t\t\treturn $row;\r\n\t\t}\r\n\t\t\r\n\t\tpublic function setMeta( $metakey, $metaValue)  {\r\n\t\t\t$existornot=$this-&gt;getMeta($metakey);\r\n\t\t\tif($existornot){\r\n\t\t\t\t$sql=\"UPDATE `options` SET\r\n\t\t\t\t`metavalue` = '$metaValue',\r\n\t\t\t\t`metaupdated` = date('Y-m-d H:i:s')\r\n\t\t\t\tWHERE `metakey` = '$metakey'\";\r\n\t\t\t\t$this-&gt;conn-&gt;query($sql);\r\n\t\t\t}else{\t\t\t\r\n\t\t\t\t$sql=\"INSERT INTO `options` (`metakey`, `metavalue`, `metaupdated`)\r\n\t\t\t\tVALUES ('$metakey', '$metaValue', date('Y-m-d H:i:s'))\";;\r\n\t\t\t\t$this-&gt;conn-&gt;query($sql);\r\n\t\t\t}\r\n\t\t\treturn 1;\r\n\t\t}<\/code><\/pre>\r\n<p>&nbsp;<\/p>\r\n<p>3. usage<\/p>\r\n<pre class=\"language-markup\"><code>$init-&gt;setMeta( 'weekly_price', \"10\");\r\n$pricings = $init-&gt;getMeta('weekly_price');<\/code><\/pre>","category_id":"1","is_private":"0","created_at":"2026-01-07T03:50:45.000000Z","updated_at":"2026-01-07T03:50:45.000000Z","category":{"id":1,"user_id":"1","name":"PHP","slug":"php-3ius","parent_id":null,"created_at":"2023-03-14T03:58:19.000000Z","updated_at":"2023-03-14T03:58:19.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"1. CREATE TABLE USING MYSQL DROP TABLE IF EXISTS `options`; CREATE TABLE `options` (   `id` int(11) NOT NULL AUTO_INCREMENT,   `metakey` var - get_meta, set_meta custom in MYSQL , PHP (Updated: January 7, 2026) - Read more about get_meta, set_meta custom in MYSQL , PHP at my programming site [SITE]","categories":[]}