-1

i used ezsql mysqli and my mysql scheme:

    id---settingname------settingcode
---------------------------------
0    doctype          <!DOCTYPE html>
1    html_lang        en
2    charset          utf8

and my php code

<?php echo $doctype; ?>
<html lang="<?php echo $html_lang; ?>">
<meta charset="<?php echo $charset; ?>">

how can i fetch stdclass object like this with ezsql mysqli;

echo $settings['doctype'];
Koray
  • 11
  • 5
  • https://stackoverflow.com/questions/3029120/how-to-access-stdclass-variables-stdclass-objectmaxid-64?rq=1 – Farkie Nov 13 '17 at 20:01
  • Possible duplicate of [How to access stdClass variables stdClass Object(\[max(id)\])=>64)](https://stackoverflow.com/questions/3029120/how-to-access-stdclass-variables-stdclass-objectmaxid-64) – Farkie Nov 13 '17 at 20:01
  • You show an array so `$settings = get_results($query, ARRAY_A);` or use `OBJECT`. – AbraCadaver Nov 13 '17 at 20:13

1 Answers1

0

Ok, i found the answer, you can change index with array_column() like this;

$settings = array_column($dbresult,'settingcode','settinguniquename');

and you can print this variable like this;

echo $settings['doctype']; echo $settings['charset']; echo $settings['anysettingname'];
Koray
  • 11
  • 5