Note that there are some explanatory texts on larger screens.

plurals
  1. POOpinion needed from a PHP Technical Architect
    primarykey
    data
    text
    <p>Please look at the code below. </p> <pre><code>require_once("initvars.inc.php"); require_once("config.inc.php"); ?&gt; &lt;?php if($latestads_count) { ?&gt; &lt;div class="latestposts"&gt; &lt;div class="head"&gt;&lt;?php echo $lang['LATEST_ADS']; ?&gt;&lt;/div&gt; &lt;table border="0" cellspacing="0" cellpadding="0" class="postlisting" width="100%"&gt; &lt;?php $sql = "SELECT a.*, ct.cityname, UNIX_TIMESTAMP(a.createdon) AS timestamp, feat.adid AS isfeat, COUNT(*) AS piccount, p.picfile AS picfile, scat.subcatname, scat.catid, cat.catname FROM $t_ads a INNER JOIN $t_cities ct ON a.cityid = ct.cityid INNER JOIN $t_subcats scat ON a.subcatid = scat.subcatid INNER JOIN $t_cats cat ON scat.catid = cat.catid LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A' AND feat.featuredtill &gt;= NOW() LEFT OUTER JOIN $t_adpics p ON a.adid = p.adid AND p.isevent = '0' WHERE $visibility_condn $loc_condn GROUP BY a.adid ORDER BY a.createdon DESC LIMIT $latestads_count"; $res_latest = mysql_query($sql) or die($sql.mysql_error()); $css_first = "_first"; while($row = mysql_fetch_array($res_latest)) { $url = buildURL("showad", array($xcityid, $row['catid'], $row['catname'], $row['subcatid'], $row['subcatname'], $row['adid'], $row['adtitle'])); ?&gt; &lt;?php if($row['isfeat']) { //$feat_class = "class=\"featured\""; $feat_img = "&lt;img src=\"images/featured.gif\" align=\"absmiddle\"&gt;"; } else { //$feat_class = ""; $feat_img = ""; } if($row['picfile']) { $picfile = $row['picfile']; $imgsize = GetThumbnailSize("{$datadir[adpics]}/{$picfile}", $tinythumb_max_width, $tinythumb_max_height); } else { $picfile = ""; } ?&gt; &lt;tr&gt; &lt;td width="15"&gt; &lt;img src="images/bullet.gif" align="absmiddle"&gt; &lt;/td&gt; &lt;td&gt; &lt;b&gt;&lt;a href="&lt;?php echo $url; ?&gt;" &lt;?php echo $feat_class; ?&gt;&gt;&lt;?php echo $row['adtitle']; ?&gt;&lt;/a&gt;&lt;/b&gt; &lt;?php if(0&amp;&amp;$row['picfile']) { ?&gt;&lt;img src="images/adwithpic.gif" align="absmiddle"&gt;&lt;?php } ?&gt; &lt;?php echo $feat_img; ?&gt;&lt;br&gt; &lt;span class="adcat"&gt; &lt;?php echo "$row[catname] $path_sep $row[subcatname]"; ?&gt; &lt;?php $loc = ""; if($row['area']) $loc = $row['area']; if($xcityid &lt; 0) $loc .= ($loc ? ", " : "") . $row['cityname']; if($loc) echo "&lt;br&gt;$loc"; ?&gt; &lt;/span&gt; &lt;/td&gt; &lt;td align="right" width="&lt;?php echo $tinythumb_max_width; ?&gt;"&gt; &lt;?php if($picfile) { ?&gt; &lt;a href="&lt;?php echo $url; ?&gt;"&gt;&lt;img src="&lt;?php echo "{$datadir[adpics]}/{$picfile}"; ?&gt;" border="0" width="&lt;?php echo $imgsize[0]; ?&gt;" height="&lt;?php echo $imgsize[1]; ?&gt;" style="border:1px solid black"&gt;&lt;/a&gt; &lt;?php } ?&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p></p> <p> </p> <p></p> <p>This is one of the code files from an existing project. As you can see, it has html, sql, php all intermixed together... and obviously difficult to maintain.</p> <p>There are around 55 files of similar size and type in this application.</p> <p>I want to refactor this code,and below are my objectives for doing so:</p> <p>1)Easy to maintain.</p> <p>2)Be able to extend easily by adding additional features.</p> <p>3)Be able to reuse this code for different but somewhat similar applications.</p> <p>I have a number of question based on the above facts:</p> <p>1) Do you think we can refactor this code into an mvc application?</p> <p>2)If we can. how much time should it take to refactor the whole project(55 files) say, for an expert programmer?</p> <p>3)Should i reuse the above code, or should i start from scratch with a existing mvc framework?</p> <p>4)How much time do we need to complete the whole project, in case we go for an existing mvc framework say symfony, zend etc.?</p> <p>5)This site as per my knowledge until now would run Mysql only(as the current db is done in mysql). Should we allow for data abstraction/data acces layers in the model(supposing there is something that performs better than Mysql, I'm not sure about this)</p> <p>7)Can we easily refactor the code to include sub-layers for model(data abstraction/access), view(further templates, view logic etc.), controller etc. in case we want to do that in future or would we need to start from scratch?</p> <p>8)Is mvc the way to go , or is there a better pattern/way than it(supposing the site is intended for hundred thousands of users)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload