all repos — h3rald @ 3823f20ada8de57b8a16651ddb10048224bbe828

The sources of https://h3rald.com

contents/articles/16.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
-----
title: "Databases supported by CakePHP"
content-type: article
timestamp: 1145251800
tags: "cakephp|webdevelopment|databases"
-----
<p>One of the most recurring questions on CakePHP User Group is probably <em>&#8220;Does Cake support X
        database?&#8221;</em>. Sure, most of us tend to use just MySQL for our websites and applications, but in certain
    situations some more <em>exotic</em> database support makes the difference. A partial answer to the question above
    could be <em>&#8220;Yes, probably, at least partially&#8221;</em>: CakePHP offers support for some database
    &#8220;natively&#8221; (i.e. Cake folks made some <em>ad hoc</em> database drivers), others through either <a
        href="http://adodb.sourceforge.net/">ADOdb</a> or <a href="http://pear.php.net/package/DB"><span
            class="caps">PEAR</span>::DB</a>.</p>
<p>CakePHP seems to use a <em>multiple level</em> database abstraction: in other words, popular abstraction layers like
    ADOdb or <span class="caps">PEAR</span>::DB have been wrapped in a &#8220;driver&#8221; which basically extends the
    DboSource class (which is the most high level database abstraction). Some people don't like the idea, because
    this means that the could be some performance issues, for one, and also that inevitably not <em>all</em> features
    offered by either ADOdb or <span class="caps">PEAR</span>::DB are used. In my very, very, very modest opinion
    (I'm not an expert on this matter), this solution focus on achieving good database compatibility leaving the
    doors open for further tinkering, if needed.</p>
<p style="float:left;"><img src="/images/pictures/postgres.png" alt="" /></p>
<p>Having said this, yes, the possibilities are good that your favorite database is supported by CakePHP, more or less.
    Of course, as repeatedly pointed out by some CakePHP core developers, Cake dev team didn't and is not going to
    test <em>every</em> database with Cake, using either of the two abstraction layers, but users are more than welcome
    to do so.</p>
<p>Let's now have a look at what is <em>known to work</em> with Cake:</p>
<p><strong>MySQL</strong> works fine, and is currently recommended as <em>preferred</em> database solution. What about
    <strong>MySQLi</strong>? Well, thanks to mappleJoe there's a (PHP5 only!) <a
        href="http://cakephp.org/pastes/show/770e73e77e4d7a3d32c2f3de3f175512">driver</a> ready to be used.
</p>
*PostgreSQL*'s support is continuously improving. Something may work, something may not: the good news is that the
folks who are using it are <a
    href="http://groups.google.com/group/cake-php/browse_thread/thread/85a29ab6ec6826a0/8eecea26ba53e1fd?q=postgres&amp;rnum=1#8eecea26ba53e1fd">sharing
    their thoughts</a> with the rest of us.
<p style="float:right;"><img src="/images/pictures/sqlite.gif" alt="" /></p>
<p><strong>SQLite</strong> is supported natively, or so it seems&#8230; what about the newest SQLite3? Yes, probably:
    there's a quick <a href="http://www.thompsonlife.net/index.php?section=9">howto</a> on ThompsonLife.net to
    make it work through the dbo_pear driver.</p>
<p><strong>Access</strong> works through the ADOdb driver, as reported in CakePHP <a
        href="http://wiki.cakephp.org/docs:databases">wiki</a> (thanks ivanp).</p>
<p><a href="http://www.filemaker.com/">FileMaker</a> is getting there: things aren't that easy, but bdb is doing
    <a
        href="http://groups.google.com/group/cake-php/browse_thread/thread/572d8dd2ba4cbdf7/dca851c795247c0b?q=database&amp;rnum=2#dca851c795247c0b">all
        his best</a> to make it work, good luck!
</p>
<p>Neil Fincham was also trying to develop a custom driver to support <a href="http://www.pervasive.com/">Pervasive</a>
    through a <a href="http://www.unixodbc.org/">unixODBC</a> driver. Best of luck!</p>
<p>For other databases, check ADOdb's <a href="http://phplens.com/adodb/supported.databases.html">list of
        supported databases</a> and use the <code>dbo-adodb</code> driver, or use <span class="caps">PEAR</span>::DB
    (for fbsql, ibase, informix, msql, mssql, mysql, mysqli, oci8, odbc, pgsql,sqlite and sybase) using the
    <code>dbo-pear</code> driver.
</p>