Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It absolutely is. Given the relational nature of MySQL and other relational databases, it is very easy to define your PHP objects and code representations of the mysql tables. Consider this overly simple class:</p> <pre><code>&lt;?php class Note { private $id private $text; private $insert_dt; private $update_dt; } ?&gt; </code></pre> <p>What this allows you to do is better organize and reuse functionality without the need for code duplication or hunting around your codebase. For instance, say I want to start printing out the insert date for every note a particular way across all pages. How would I do this? I could potentially have to change every page on the site.</p> <p>If we have properly defined setters and getters, this becomes an exceedingly simply task. I should only have to replace the formatted return string in 1 (very obvious) location:</p> <pre><code>&lt;?php class Note { // ... public function getFormattedInsertDate() { return date( "M, Y", $this-&gt;insert_dt ); } } ?&gt; </code></pre> <p>Admittedly, this all seems very excessive and time consuming on a small scale. I remember building a personal site for myself in college when I had extensive OO experience. I was learning PHP at the time and for the site I tended to use inline code simply for the speed. It worked fine, was very fast and lightweight. I didn't understand the hullabaloo over web frameworks, as they felt overly "heavy".</p> <p>The issues arise after the fact during maintenance. When you return to code 6 months or years later, you try and figure out where this call was, or why you have to change it in 8 places to fix a bug. These are the feelings caused by bad coupling - cohesion in your codebase.</p> <p>Luckily, many frameworks have sprung up over the years to not only support but encourage and enforce this behavior. If you haven't I would strongly suggest looking into CakePHP or Code Igniter. They are both pretty easy to leaner frameworks that really nail down these concepts well, as well as provide excellent introductory tutorials to walk you through creating a blog website.</p> <p>I hope this helps. Let me know if I missed anything and I'll update this as needed.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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