Welcome Guest, Not a member yet? Register   Sign In
DB Query Returns
#2

[eluser]ELRafael[/eluser]
[quote author="Daburn" date="1192821087"]Hi Guys

I'm trying to become acquainted with CodeIgniter but now facing a problem with the returns of my DB query. I want to give all the values with no content the value "keine Angaben". Because else, the table cells with no content won't be draw.

My Model:
Code:
function list_stocks() {
            $query = $this->db->query('SELECT * FROM stocks');
            foreach ($query->result() as $value) {
                if (strlen($value) == 0) $value = "keine Angaben";
            }
            return $query;
        }
[/quote]

change this
Code:
if (strlen($value->the_field_of_stocks_table) == 0) $value = "keine Bier heute :(";

The rest is the best :-P

[quote author="Daburn" date="1192821087"]
My Controller:
Code:
$this->load->model('Home_model','', TRUE);
$data['query'] = $this->Home_model->list_stocks();
                    
$this->load->view('loader', $data);

Obviously, $query returns an object, but I'm not sure how to realise it else without adressing each result separately with:
Code:
nameindustry == "") $row->name = " "
if ($row->price == "") $row->price = " "

Thanks a lot,
Daburn[/quote]


Messages In This Thread
DB Query Returns - by El Forum - 10-19-2007, 08:11 AM
DB Query Returns - by El Forum - 10-19-2007, 08:18 AM
DB Query Returns - by El Forum - 10-19-2007, 08:22 AM
DB Query Returns - by El Forum - 10-19-2007, 08:30 AM
DB Query Returns - by El Forum - 10-19-2007, 08:38 AM
DB Query Returns - by El Forum - 10-19-2007, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB