php show the number of times a relationship appears


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

1 answer


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 ();


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

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

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


$ number of records = count ($ record);

answered by 22.11.2018 в 18:03