Welcome Guest, Not a member yet? Register   Sign In
Get object from id
#6

(04-03-2018, 09:01 AM)qury Wrote: I do not have your table layout, but i believe you have a table called joueurs and in there a field called name.

My understanding is that if you do not specify the field names   select('*')  , the sql query will return  all the column headers.

You could do this:
PHP Code:
function get_all_statistics()
{
 
  $this->db->select([
 
                 'statistics.stat_id',
 
                 'statistics.leg_id',
 
                 'statistics.darts',
 
                 'statistics.finish',
 
                 'statistics.reste',
 
                 'statistics.max',
 
                 'joueurs.id',
 
                 'joueurs.name'
]);
 
  $this->db->from('statistics');
 
  $this->db->join('joueurs''joueurs.id = statistics.player_id');
 
  return $query $this->db->get()->result();


Then in your view you should simply refer to them as:
PHP Code:
{% for stat in statistics %}
 
  <tr>
 
      <td>{{stat.stat_id}}</td>
 
      <td>{{stat.leg_id}}</td      
       
<td>{{stat.name}}</td>
 
      <td>{{stat.darts}}</td>
 
      <td>{{stat.finish}}</td>
 
      <td>{{stat.reste}}</td>
 
      <td>{{stat.max}}</td>
 
  </tr>
{% endfor %} 

Oh no I'm so dumb  Big Grin. I was stuck 1 week for such a stupid thing lol. Thank you very much. Yes, just using stat.name works.
Reply


Messages In This Thread
Get object from id - by reysing - 03-29-2018, 05:05 AM
RE: Get object from id - by php_rocs - 03-29-2018, 09:37 AM
RE: Get object from id - by InsiteFX - 03-30-2018, 04:02 AM
RE: Get object from id - by reysing - 04-03-2018, 06:23 AM
RE: Get object from id - by qury - 04-03-2018, 09:01 AM
RE: Get object from id - by reysing - 04-05-2018, 07:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB