php show the number of times a relationship appears

0

Hello very good that such I have a problem in php and I do not want to save the value in the database, I would like to know if you know any way to see the times that appears a relation fingers tables in the database ie I I have a class and another that is related to another class which I would like to know how many times is related in the bd to know if it is available or not thanks and greetings. I am using silverstripe 3.

    
asked by zekamodz 22.11.2018 в 17:46
source

1 answer

0

Hello, I did not understand very well what you want. But I calculate that doing a select * from with an inner joinlo you convert it into an array and you ask if it is NOT empty you do a count ();

EXAMPLE

$ sql="select * FROM table1 INNER JOIN table2 WHERE table1.id = table2.id"

$ result = mysql_query ($ connection, $ sql);

while ($ registration = mysqli_fetch_assoc ($ result)) {

}

$ number of records = count ($ record);

    
answered by 22.11.2018 в 18:03