Welcome Guest, Not a member yet? Register   Sign In
Get only a value from table ?
#1

[eluser]chefnelone[/eluser]
Hello,

I'm trying to get just a single value from a database table in a model method.

In my table I have fields named: 'image_name' and 'id_product'.

Then I try to the value of image_name where id_product = 15

I tried with: but the third line is wrong..

model_getData.php
Code:
$productImages = $this->db->get_where('products_images', array('id_product' => 15), '1');
$productImages = $productImages->result();
$miValue =  $productImages -> image_name; //THIS IS WRONG
$this->firephp->log( $miValue );


What's the way to do this?
#2

[eluser]n0xie[/eluser]
Code:
$productImages = $productImages->row();
#3

[eluser]chefnelone[/eluser]
you mean to replace:

Code:
$productImages = $productImages->result();

whith:

Code:
$productImages = $productImages->row();

I tried it, but still not working
Code:
$productImages = $this->db->get_where('products_images', array('id_product' => 15), '1');
$productImages = $productImages->row();
$productImages =  $productImages -> image_name;
$this->firephp->log( $productImages );



I also tried
Code:
$productImages = $this->db->get_where('products_images', array('id_product' => 15), '1');
$productImages = $productImages->result();
$productImages =  $productImages->row();
$this->firephp->log( $productImages );
#4

[eluser]danmontgomery[/eluser]
Code:
$productImages = $this->db->get_where('products_images', array('id_product' => 15), '1');
$productImages = $productImages->row();
$miValue =  $productImages->image_name;
$this->firephp->log( $miValue );

Is correct... If that's not working I would look at the query being generated, ensuring that it's returning a result and that it's returning the result you're expecting (the correct row and columns). It would also help if you were more specific than "not working".




Theme © iAndrew 2016 - Forum software by © MyBB