Связанные таблицы по skills_id, нужно вывести ассоциативный массив в php ,я делаю так :
$db = Db::getconnection();
$skillslist = [];
$result = $db->query('SELECT * FROM skills LEFT OUTER JOIN about ON skills.skills_id = about.skills_id');
$result -> execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$skillslist[$row['skill_name']][] =$row;
}
//$row = $result->FETCHALL(PDO::FETCH_COLUMN|PDO::FETCH_GROUP);
return $skillslist;
выводится это:
array(5) {
["frontend"]=>
array(4) {
[0]=>
array(5) {
["skills_id"]=>
string(1) "1"
["skill_name"]=>
string(8) "frontend"
["about_id"]=>
string(1) "1"
["about_name"]=>
string(10) "html & css"
["about_val"]=>
string(3) "100"
}
[1]=>
array(5) {
["skills_id"]=>
string(1) "1"
["skill_name"]=>
string(8) "frontend"
["about_id"]=>
string(1) "3"
["about_name"]=>
string(11) "js & jquery"
["about_val"]=>
string(2) "20"
}
[2]=>
array(5) {
["skills_id"]=>
string(1) "1"
["skill_name"]=>
string(8) "frontend"
["about_id"]=>
string(1) "4"
["about_name"]=>
string(4) "sass"
["about_val"]=>
string(2) "20"
}
[3]=>
array(5) {
["skills_id"]=>
string(1) "1"
["skill_name"]=>
string(8) "frontend"
["about_id"]=>
string(1) "5"
["about_name"]=>
string(9) "bootstrap"
["about_val"]=>
string(2) "18"
}
}
["backend"]=>
array(4) {
[0]=>
array(5) {
["skills_id"]=>
string(1) "2"
["skill_name"]=>
string(7) "backend"
["about_id"]=>
string(1) "6"
["about_name"]=>
string(3) "php"
["about_val"]=>
string(2) "20"
}
[1]=>
array(5) {
["skills_id"]=>
string(1) "2"
["skill_name"]=>
string(7) "backend"
["about_id"]=>
string(1) "7"
["about_name"]=>
string(5) "mysql"
["about_val"]=>
string(2) "25"
}
[2]=>
array(5) {
["skills_id"]=>
string(1) "2"
["skill_name"]=>
string(7) "backend"
["about_id"]=>
string(1) "8"
["about_name"]=>
string(8) "composer"
["about_val"]=>
string(2) "20"
}
[3]=>
array(5) {
["skills_id"]=>
string(1) "2"
["skill_name"]=>
string(7) "backend"
["about_id"]=>
string(1) "9"
["about_name"]=>
string(7) "laravel"
["about_val"]=>
string(2) "20"
}
}
["workflow"]=>
array(4) {
[0]=>
array(5) {
["skills_id"]=>
string(1) "3"
["skill_name"]=>
string(8) "workflow"
["about_id"]=>
string(2) "10"
["about_name"]=>
string(3) "git"
["about_val"]=>
string(2) "20"
}
[1]=>
array(5) {
["skills_id"]=>
string(1) "3"
["skill_name"]=>
string(8) "workflow"
["about_id"]=>
string(2) "11"
["about_name"]=>
string(4) "gulp"
["about_val"]=>
string(2) "20"
}
[2]=>
array(5) {
["skills_id"]=>
string(1) "3"
["skill_name"]=>
string(8) "workflow"
["about_id"]=>
string(2) "12"
["about_name"]=>
string(5) "bower"
["about_val"]=>
string(2) "20"
}
[3]=>
array(5) {
["skills_id"]=>
string(1) "3"
["skill_name"]=>
string(8) "workflow"
["about_id"]=>
string(2) "13"
["about_name"]=>
string(3) "ssh"
["about_val"]=>
string(2) "20"
}
}
}
Просто мне кажется что-то не то,потому что возникают кое какие трудности