• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ony one record

#1
model:
PHP Code:
public function getDatum($datum_id)

{        
    
$db      = \Config\Database::connect();
    
$builder $this->db->table('dnevnik_zapis');
    
$builder->select('*');
    $builder->join('dnevnik_datum''datum_id = datum_dnevnik_id');
    return $builder->getWhere(['datum_id' => $datum_id]); 

controllers

PHP Code:
       public function datum($datum_id)
    {
        $model = new Dnevnik_model();
        $data['datum_id'] = $model->getDatum($datum_id)->getRow();
        echo view('dnevnik_datum_view'$data);
    

View
PHP Code:
   <?= $datum_id->dnevnik_id;?><br>
<?= $datum_id->datum_d;?><br>
<?= $datum_id->datum_dnevnik_id;?><br>
<?= $datum_id->opis;?><br> 


prints me only one record from the table,

I have 2 records in the table


?
Reply

#2
Where is the question?
Reply

#3
Your asking it in your getWhere to get it by id which will only return one record for that id.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(01-21-2021, 12:21 PM)vojkoz Wrote:
PHP Code:
$data['datum_id'] = $model->getDatum($datum_id)->getRow(); 

https://codeigniter.com/user_guide/datab...s.html#id2

Quote:getRow()

This method returns a single result row.

That's also why you only have one result.
Reply

#5
(01-22-2021, 02:13 AM)craig Wrote:
(01-21-2021, 12:21 PM)vojkoz Wrote:
PHP Code:
$data['datum_id'] = $model->getDatum($datum_id)->getRow(); 

https://codeigniter.com/user_guide/datab...s.html#id2

Quote:getRow()

This method returns a single result row.

That's also why you only have one result.


tnx.. 
sorry, I'm a new to this.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.