Bank query problem with Codeigniter

Asked

Viewed 37 times

1

I have a table in the bank (use_shopBlock), which locks a button in the view, but when I give a <?php var_dump($shopBlock);?> the result is NULL.

My view:

<?php
             $shopBlock = $this->main_model->configBlock('use_shopBlock');

                  if($shopBlock == 9){
                     echo '
                        <button type="button" id="open-shop" class="btn btn-primary"><i class="fa fa-shopping-cart" aria-hidden="true"></i>Abrir Minha Loja</button>
                     ';
                  }
               ?>

My model:

 public function configBlock($column = false) {
        $this->db->limit(1);

        if ($column) {
            $this->db->select($column);
        }

        $query = $this->db->get('users');
        $query = $query->result();

        if ($query) {
            if ($column) {
                return $query[0]->$column;
            } else {
                return $query[0];
            }
        } else {
            return false;
        }
    }

I will attach how my table was made in MYSQL inserir a descrição da imagem aqui

When the user registers, adds the value 8 in the shopBlock table, and the administrator, when changed to "Store Released", changes to the value 9.

This value 9, should release the button in the view.

Code that changes value in admin:

<div class="form-group">
                        <label>Ativar loja</label><br>
                            <select class="form-control" name="shopBlock">
                            <option <?=(($e && $item->use_shopBlock == '9') ? 'selected' : '')?> value="9">Loja Liberada</option>
                            <option <?=(($e && $item->use_shopBlock == '8') ? 'selected' : '')?> value="8">Loja Bloqueada</option>
                        </select>
                    </div
  • Where is the post code for tbl change?

  • You refer to the code that changes the value from 8 to 9 and vice versa? is there, but the problem is not that. The problem that is not getting the value in the table.

  • I think the function result( ) of the Codeigniter is returning null, and therefore running the line return false; because probably the table is empty.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.