I'm a beginner with Symfony.
I have 2 entities: Stock and Sales. Both have their associated database tables.
Stock has the following structure:
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| description | varchar(255) | NO | | NULL | |
| input | int(11) | NO | | NULL | |
| output | int(11) | NO | | NULL | |
| balance | int(11) | NO | | NULL | |
| created | datetime | NO | | NULL | |
| updated | datetime | NO | | NULL | |
| unitcost | double | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
Sales has the following structure:
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| cost | double | NO | | NULL | |
| date | datetime | NO | | NULL | |
| profitloss | double | NO | | NULL | |
| sid | int(11) | YES | MUL | NULL | |
+------------+----------+------+-----+---------+----------------+
I am attempting to create a one-to-many relationship between Stock and Sales.
Stock is a list of all items for sale in a store. Sales is the record of actual purchases of any item in the Stock database table.
It was in the process of displaying my first Sales item that I experienced a major problem.
To display a Sale, my vision was to execute an SQL statement between both table where Sales:sid == Stock:id - I ran into newbie problems as I couldn't find a straight forward way of doing the kind of SQL execution I have become accustomed to.
How can I make a start on this? I want to print details of each sale by fetch related data from the Stock table.