php


How to extend the “album” model to return other objects from the database?


The ZF2 user guide explains how to set up and query the database using the Table Data Gateway pattern.
I wonder what would be the best approach to extend this design with another table, let's say "tracks".
It's easy to just copy the existing method of using the serviceManager to create a new tableGateway and object for the tracks table and use a controller to get tracks for a specific album. But it feels wrong to do it that way.
I'm thinking about extending the Album model with a method that returns the tracks for this specific album. But to do so I'd have to use the tracks tableGateway inside the Album model - and I'm not sure how to set that up.
Using the serviceManager inside the model to get access to the track gateway and object seems wrong. Or do I inject them into the object somehow?
What is the preferred way to do something like this?
When you reach the point where you are saying "it feels wrong to do it that way" you should stop thinking about the solution and reason about the problem. Your problem might be that you don't know your problem enough to pick a solution.
When you do software design, you shouldn't ask yourself to make arbitrary design choices. Instead, you must identity your key requirements and pick the simplest solution that fill these requirements.
Here, I would advise you to stick to the simplest solution: having a completely different tableGateway and business object, not linked at all to the album business object.
BUT since you are using a ZF2 guide, you clearly want to learn more about ZF2. This is one of your design requirement so I would advise you to use ZF2 tools to solve your problem in many different ways.
You can use the service manager factories and abstract factories, build another module, use a different storage, etc.

Related Links

PHP conditional assistance
PHP: Error :Syntax to be user near '='a_name','='another_name' at line 1
File not saving in images directory
Using offline server in PHP
Group functions within class
wordpress custom url with dummy content
menu 2 result to use for SQL search
img tag images not showing in server using html in TCPDF
wordpress mail header set else plain text
Is using strpos() before preg_replace() faster? [closed]
how to hide form action from user
Call methods inside public folder - Laravel
How can I show the content of a custom xml file in a Wordpress page?
InvalidValueError: in property latLng: not a LatLng or LatLngLiteral: not an Object
Paypal sandbox not responding to cUrl call
Show value if update isset [duplicate]

Categories

HOME
protocol-buffers
plesk
clearcase
jms
antd
operating-system
initialization
mirc
gallery
gentelella
dji-sdk
linker
google-search-console
javafx-8
msmq
azure-graph-api
xades4j
sslhandshakeexception
sql-injection
android-contacts
exe
codefluent
altium-designer
pymongo
pubxml
android-cardview
sendmessage
nic
infopath2010
mapnik
actframework
private-key
om-next
db2-luw
express-session
subclassing
love2d
installanywhere
gitolite
selenide
swfupload
oracle-bmcs
directwrite
tinyioc
nothing
kendo-editor
rcharts
gawk
cefpython
logical
openquery
visual-studio-monaco
gcloud-node
nsdata
node-glob
vaadin4spring
i2b2
msgpack
google-maps-api-2
nastran
wso2ml
swagger-maven-plugin
mobilefirst-server
ampersand
phonegap-facebook-plugin
operands
fasterxml
producer
back
siena
senchatouch-2.4
roxy-fileman
compiler-flags
frontbase
google-code-prettify
cgrectmake
cakeyframeanimation
prefuse
opends
algol68
n-queens
gwt-celltable
asio
server-variables
firefly-mv
botnet
nsconnection
printqueue
anonymous-types
regression-testing
zend-test
html-generation

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile