1
I am developing a website for a musical project and I am having difficulty with select, is the following, I have 2 tables an album that contains information from the cd (artwork, album title, name of the songs, etc), the other table calls album_links that has the links from where the cd will be available to buy (Amazon, Bandcamp, itunes, etc).
I made a select in the album table and all information appears normally, but in the album_links table when it is done select the data is repeated if you have more than one cd registered.
The idea is that only show the links to each registered cd. Ex:
CD 1 link1 Link2 link3
CD 2 link1
The only table that has foreign key (referring to album table) is the album_links table, I have tried to make a Join Inner between the two tables, and also other selects, but for now without success.
I had the same problem in another project when I was developing a photo gallery, the data was repeated and I still could not solve this problem too.
Does anyone have any idea what it might be?
Here’s the Front-End code
public function listing() {
$ListRelease = new ModelsRead();
$ListRelease->ExeRead('album');
$this->Result = $ListRelease->getResult();
return $this->Result;
}
public function listingLinks() {
$ListReleaseLink = new ModelsRead();
$ListReleaseLink->ExeRead('album_links');
$this->Result = $ListReleaseLink->getResult();
return $this->Result;
}
In both functions the Exeread does: SELECT * FROM table
The Modelsread class has the functions
public function ExeRead($Table, $Terms = null, $ParseString = null) {
if (!empty($ParseString)):
parse_str($ParseString, $this->Values);
endif;
$this->Select = "SELECT * FROM {$Table} {$Terms}";
$this->ExecuteInstruction();
}
public function fullRead($Query, $ParseString = null) {
$this->Select = (string) $Query;
if(!empty($ParseString)):
parse_str($ParseString, $this->Values);
endif;
$this->ExecuteInstruction();
}
Database: mysql
Here’s the Inner Join I tried to do:
public function listingLinks() {
$ListReleaseLink = new ModelsRead();
$ListReleaseLink->fullRead("SELECT alblink.*, alb.album_title album FROM
album_links alblink
INNER JOIN album alb ON alb.id = alblink.album_id");
$this->Result = $ListReleaseLink->getResult();
return $this->Result;
}
However it repeats the data, the result I want is that for each album show the respective registered links.
Tabela album
id
album_title
picture
album_tracks
album_members
album_release_date
producers
studio
created
modified
Tabela album_links
id
name
picture
link
album_id
created
modified
In this project I am using MVC standard
Post the codes so we can help you. Specify more your problem. Which language you are using?
– Paulo Sérgio Filho
I’m using Object-Oriented PHP
– Robson Luiz Dos Santos
Post your code so I can see what you’re doing.
– Paulo Sérgio Filho
Using a plugin? Or the Modelsread() class you made?
– Paulo Sérgio Filho
No, I’m not using any plugin
– Robson Luiz Dos Santos
Yes, the Modelsread class I created
– Robson Luiz Dos Santos
The whole structure I’m using is a "mini" framework that I developed in a course.
– Robson Luiz Dos Santos
Without code we can not understand. However what seems to me: - A Join in the table badly done or not done. - A distinct clause can solve the problem. This in the context of the sql query.
– Ricardo Ferreira
@Robsonluizdossantos put the query with the Internet you were making to analyze.
– Thiagosilr
This does not answer the question. When you have reputation enough, you’ll be able to leave comments on any post but until then, write only answer that no depend on more information of who asked. - Of Revision
– user28595
One thing I think is that I don’t know how to do the Internet correctly, because what I tried he repeated the data, and the idea is that when doing the select show the information of the registered cd and the registered links to this cd. Ex: CD1 link1 Link2 link3, CD2 link1 Link2, another thing I’ve already thought is also the problem may be in the relationship of the tables.
– Robson Luiz Dos Santos
Besides the Internet I also posted the structure of the tables
– Robson Luiz Dos Santos