{"id":2745,"date":"2020-04-13T09:58:33","date_gmt":"2020-04-13T08:58:33","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2745"},"modified":"2022-02-17T07:13:48","modified_gmt":"2022-02-17T07:13:48","slug":"database-table-with-list-of-providers","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/database\/example-uses\/database-table-with-list-of-providers","title":{"rendered":"DB table list of providers"},"content":{"rendered":"\n<p>Create a table with the following columns:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>EmailProvider (AUTO INC int primary key)<\/li><li>EmailProviderName<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/\/**********************************************\n\/\/**********************************************\n\/\/********** READ ALL EMAIL PROVIDERS **********\n\/\/**********************************************\n\/\/**********************************************\n\/* Example usage\n  \/\/Convert EmailProvider ID value to Name\n  $Results= db_email_providers_read_all();\n  foreach ($Results as $Entry)\n  {\n    if ($EmailProvider == $Entry&#91;'EmailProvider'])\n      $EmailProvider = $Entry&#91;'EmailProviderName'];\n  }\n*\/\nfunction db_email_providers_read_all ()\n{\n  global $wpdb;\n  \n  $sql = \"SELECT * FROM {$wpdb->prefix}my_table_name ORDER BY EmailProviderName ASC\";\n  if (current_user_can('administrator'))\n    $wpdb->show_errors();\n  $Results = $wpdb->get_results($sql, ARRAY_A);\n  if (count($Results) == 0)\n    $Results = array();\n\n  \/\/Insert default None entry into the Results array as index 0 (the rest of the array moves down)\n  $NoneEntry = array(\n    \"EmailProvider\"=>0,\n    \"EmailProviderName\"=>\"Not Selected\"\n  );\n  array_unshift($Results,$NoneEntry);\n\n  \n  return($Results);    \n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Create a table with the following columns: EmailProvider (AUTO INC int primary key) EmailProviderName<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[235],"tags":[],"class_list":["post-2745","post","type-post","status-publish","format-standard","hentry","category-example-uses"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2745"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2745\/revisions"}],"predecessor-version":[{"id":2747,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2745\/revisions\/2747"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}