I must to join company_type add get All datas from companies.
index.php
include 'Company.php';
$company = new Company();
$companyData = $company->getCompanyById($companyId);
var_dump($companyData);
Company.php
class Company
{
public function getCompanyById($companyId)
{
$sql="SELECT companies.id, companies.company_type_id, companies.name, companies.email
FROM companies
INNER JOIN company_type
ON company_type.name = companies.company_type_id WHERE companies.id = $companyId ";
$query = $this->db->pdo->prepare($sql);
$query->bindValue(':company_id', $companyId);
$query->execute();
$result = $query->fetch(PDO::FETCH_OBJ);
return $result;
}
}
MYSQL Tables
companies
id | name | email | company_type_id
company_type
id | company_type