Sql Join

74 views
Skip to first unread message

Muhammad Shahzad

unread,
Oct 25, 2017, 8:25:47 AM10/25/17
to Fat-Free Framework

Hi,

How is it possible to get data from two table and display it in a view, I have customer and admin_user table, an admin user have created customer and admin user id saved into customer table but now problem is how can I show admin user name in view?

here is my code:


Controller:


public function index($f3){
$f3
->set("DEBUG",3);
$customer
= new \Model\Customer;
list
($filter, $filter_str) = $this->_buildFilter();
$customers
= $customer->paginate($args["page"], 50, $filter_str); $f3->set("data", $customers);
}

Model

class Customer extends \Model {
protected $_table_name = "customer";
public static function create(array $data){
try{
   
return parent::create($data);
 
}catch(Exception $e){ throw $e; }
 
}
}


Vester

unread,
Oct 25, 2017, 5:38:15 PM10/25/17
to Fat-Free Framework
Hi Muhammad!

This is a use case for an ORM such as Cortex (https://github.com/ikkez/f3-cortex); integrates nicely with F3.

It makes very easy to get data from related tables once you setup up relationships among them.

Best regards,

s.
Reply all
Reply to author
Forward
0 new messages