$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);
public function getCars()
{
$cars = new ArrayObject();
$purchases = Purchase::where('user_id', $this->id)->where('type', 'car')->get();
foreach($purchases as $item) {
$cars->append(Car::where('id', $item->car_id)->first());
}
return $cars;
}