Re: camelCase in MySQL
Catalin Francu <cata <at> francu.com>
2008-04-02 20:55:50 GMT
Thank you both for the prompt responses this time! Actually, I think I
just found the problem. I was using ADODB_ASSOC_CASE, but it seemed to
be ignored. I took a look at the code and found that
adodb-active-records.inc.php uses $ADODB_ASSOC_CASE in several places
(mind the dollar sign). Other files use the constant ADODB_ASSOC_CASE
(no dollar sign). The manual instructs us to define the *constant*,
not the *variable*, but then all the checks done against the
*variable* in adodb-active-records.inc.php ignore the *constant*
value, and behave as if the *variable* was set to 0 (because it is
null).
I fixed this problem by declaring this in my code before including the
ADODB files:
define('ADODB_ASSOC_CASE', 2);
$ADODB_ASSOC_CASE = 2;
I'm using the RPM php-adodb-4.95-1.a under Fedora Core 8, but I looked
at the sources for adodb-5.04a at sourceforge.net and the problem
seems to still be there.
Now tell me I'm not crazy.
Once again, thanks for ADOdb. I don't want to remember what life was
like before I started using it.
Catalin
On Wed, Apr 2, 2008 at 1:04 PM, Alfredo Yong <alfredoyong <at> gmail.com> wrote:
> Ok, we are not that dead. Tell me why you want to have the filed name. I use
> FetchNextObj, and everything preserves its database field name in postgresql
>
>
>
>
>
> On Wed, Apr 2, 2008 at 2:34 PM, Catalin Francu <cata <at> francu.com> wrote:
>
> >
> >
> >
> > Ping... Is this list mostly dead? =/
> >
> > Once again, my problem is that MySQL fields like "zoneId" are
> > converted to PHP fields like "zoneid", with all letters lowercased. I
> > would like to keep the camelCase for readabilty, and I would like to
> > achieve this before the code grows too large.
> >
> > On Mon, Feb 25, 2008 at 2:21 PM, Catalin Francu <cata <at> francu.com> wrote:
> > > Hi,
> > >
> > > Is it possible to preserve the case of the field names when using
> > > ADOdb active records over MySQL? Currently, all my field names are
> > > lowercased, and ADODB_CASE_ASSOC does not seem to have any effect. In
> > > the example below, the MySQL field "zoneId" is mapped to the PHP
> > > property "zoneid", whereas I would like it to be "zoneId".
> > >
> > > The MySQL table definition is:
> > >
> > > mysql> describe Establishment;
> > > +---------+--------------+------+-----+---------+----------------+
> > > | Field | Type | Null | Key | Default | Extra |
> > > +---------+--------------+------+-----+---------+----------------+
> > > | id | int(11) | NO | PRI | NULL | auto_increment |
> > > | name | varchar(255) | YES | | NULL | |
> > > | zoneId | int(11) | NO | MUL | | |
> > > | website | varchar(255) | YES | | NULL | |
> > > +---------+--------------+------+-----+---------+----------------+
> > > 4 rows in set (0.01 sec)
> > >
> > > The PHP code is:
> > >
> > > class Establishment extends ADOdb_Active_Record {
> > > public $_table = 'Establishment';
> > >
> > > public static function loadById($id) {
> > > $e = new Establishment();
> > > $e->load("id=$id");
> > > var_dump(ADODB_ASSOC_CASE);
> > > var_dump($e->getAttributeNames());
> > > var_dump($e->zoneId);
> > > return $e;
> > > }
> > > }
> > >
> > > And the output from calling the method is:
> > >
> > > int(2)
> > > array(4) { [0]=> string(2) "id" [1]=> string(4) "name" [2]=>
> > > string(6) "zoneid" [3]=> string(7) "website" }
> > > Notice: Undefined property: Establishment::$zoneId in
> > > /home/cata/public_html/lingura/phplib/activeRecords.php on line 29
> > >
> > >
> > >
> > > In any case, thanks for ADOdb! It makes my life much easier.
> > >
> > > Catalin
> > >
> >
> > -------------------------------------------------------------------------
> > Check out the new SourceForge.net Marketplace.
> > It's the best place to buy or sell services for
> > just about anything Open Source.
> >
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> > _______________________________________________
> > ADodb-general mailing list
> > ADodb-general <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/adodb-general
> >
>
>
>
> --
> Alfredo Yong
> Sistemas web
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace