title: Extending Propel to emulate database functions
body: <p>I need to translate an application from MySQL to SQL Server.</p>
  
  <p>There are many hard-coded queries involving MySQL database functions like <strong>NOW()</strong>, <strong>LCASE()</strong>, <strong>MATCH() AGAINST()</strong>, that has equivalent in SQL Server, but with a different syntax and structure.</p>
  
  <p>I choose <strong>Propel</strong> because it seems to be easy-to-use.</p>
  
  <p>I'm looking for a way to emulate database functions like <strong>NOW()</strong> <em>{MySQL}</em> and <strong>GETDATE()</strong> <em>{SQL Server}</em> by extending Propel classes.</p>
  
  <p>I think something like this:</p>
  
  <pre><code>$result = Function::NOW(); // MySQL
  $result = Function::GETDATE(); // SQL Server
  </code></pre>
  
  <p>When the function accepts parameters, like <strong>LCASE()</strong> <em>{MySQL}</em> or <strong>LOWER()</strong> <em>{SQL Server}</em>, it could be like this:</p>
  
  <pre><code>$table = new MyTable();
  $result = Function::LCASE($table-&gt;getName()); // MySQL
  $result = Function::LOWER($table-&gt;getName()); // SQL Server
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$table = new MyTable();
  $result = Function::MD5($table-&gt;getPassword()); // MySQL
  $result = Function::HASHBYTES('MD5', $table-&gt;getPassword()); // SQL Server
  </code></pre>
  
  <p>The perfect solution would be if I can create equivalence between two functions with the same purpose from different databases (MySQL and SQL Server).</p>
  
  <p>So, instead of using <strong>Function::HASHBYTES()</strong> in my PHP code, I could always use <strong>Function::MD5()</strong>, because it is more simple, and when my application is connected to a SQL Server Database, internally, <em>HASHBYTES()</em> is invoked.</p>