Closed GoogleCodeExporter closed 9 years ago
"PHP is assumed case insensitive"
This is not correct. PHP is inherently case-sensitive.
If you have a table named "client" and you want a model named "client"
generated, you
should use:
model client
If you have a table named "client" and you want a model named "Client"
generated, you
should use:
model Client client
That is the proper way to use the model command.
Original comment by xx66...@gmail.com
on 19 Dec 2009 at 7:15
A small rephrasing: PHP is case insensitive when it comes to class names, and
this
will not change in the future. See http://bugs.php.net/bug.php?id=26575&edit=1
A simple test case.
<?php
class CaseSensitive {
}
class casesensitive {
}
?>
results in
Fatal error: Cannot redeclare class casesensitive in test.php on line 7
Yii willfully generates identical class names, and thus willfully generates
errors. Users
should at least be notified of this, and preferably protected against this.
Original comment by dylan.verheul
on 20 Dec 2009 at 7:13
Addendum:
In http://www.yiiframework.com/doc/guide/database.ar the Yii documentation
advises users to user all lowercase table and field names. Combined with the
current
(IMHO wrong) case handling of yiic shell, this will lead to users experiencing
errors.
Quote:
Info: In this guide, we name columns using camel cases (e.g. createTime). This
is
because columns are accessed in the way as normal object properties which also
uses camel-case naming. While using camel case does make our PHP code look more
consistent in naming, it may introduce case-sensitivity problem for some DBMS.
For
example, PostgreSQL treats column names as case-insensitive by default, and we
must quote a column in a query condition if the column contains mixed-case
letters.
For this reason, it may be wise to name columns (and also tables) only in
lower-case
letters (e.g. create_time) to avoid any potential case-sensitivity issues.
Original comment by dylan.verheul
on 23 Dec 2009 at 6:47
This problem is exacerbated when developing on Windows and deploying to Linux.
By default, mySQL on Windows forces table names to lowercase.
When deployed to Linux without modification, the models cannot find the
appropriate
tables.
Original comment by site.sen...@gmail.com
on 29 Jan 2010 at 10:30
Original comment by qiang.xue
on 31 Jan 2010 at 9:21
Will leave it as is. Yii requires class file names to be the same as the class
name
(case-sensitive on *nix systems) if auto-loading is needed. The syntax of model
command is: model ClassName [table-name]. For this reason, you should be careful
about the case of the class name.
Original comment by qiang.xue
on 1 Feb 2010 at 10:41
Polite request to reconsider.
1) PHP is a multi-platform language. Some PHP platform OS's do not support case
sensitivity in file names.
2) PHP file names may be case sensitive on SOME *nix systems, but the class
name
casing in PHP is purely cosmetic (see my comment #2 above).
3) (Combining 1 and 2) Depending on file case names means Yii would support
user.php and User.php as separate files containing separate classes user and
User,
which PHP would not allow.
The logical step for Yii would be to realize the above, and fix it (or at least
deprecate
the file name case sensitivity and make yiic shell act smarter).
Original comment by dylan.verheul
on 3 Feb 2010 at 6:05
The problem is when you run "model user", should Yii generate "user.php" or
"User.php"? Not all people like being forced to use Camel case in their class
names.
Original comment by qiang.xue
on 3 Feb 2010 at 1:29
The current model command works well. MHO is that it does not need changing as
you
will get the results you desire if you understand and use it correctly.
Original comment by wapr...@gmail.com
on 3 Feb 2010 at 2:24
to be precise..
PostgreSQL does not treat column (or any) names as case-insensitive.
it's client library does fold unquoted names/identifiers to lowercase.
hth.
Original comment by aa.del...@yahoo.com
on 13 Jul 2010 at 6:27
Original issue reported on code.google.com by
dylan.verheul
on 18 Dec 2009 at 10:42