Skip to content

Instantly share code, notes, and snippets.

@mehmetsarr
Created November 28, 2022 11:41
Show Gist options
  • Save mehmetsarr/96eb033d5b14dd67c06004c02db7e68d to your computer and use it in GitHub Desktop.
Save mehmetsarr/96eb033d5b14dd67c06004c02db7e68d to your computer and use it in GitHub Desktop.
CodeIgniter 4 join İşlemi
<?php namespace App\Controllers;
use App\Models\CustomModel;
use App\Controllers\BaseController;
use CodeIgniter\Controller;
class Custom extends BaseController
{
public function index()
{
$model = new CustomModel();
$data=[
'custom' => $model->joinCustom()
];
return view('costumview', $data);
}
//--------------------------------------------------------------------
}
<?php namespace App\Models;
use CodeIgniter\Model;
class CustomModel extends Model
{
public function joinCustom()
{
return $this->db->table('tbl_custom')
->join('urunler', 'urunler.urun_id = urun_siparis.urun_id', 'left')
->join('siparisler', 'siparisler.siparis_id = urun_siparis.siparis_id', 'left')
->join('kullanicilar', 'kullanicilar.kullanici_id = siparisler.kullanici_id', 'left')
->get()->getResultArray();
}
}
<?php $no=1; foreach ($custom as $key => $value) { ?>
<td><?= $no++; ?></td>
<td><?= $value['urun_adi']; ?></td>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment