推进区分大小写的phpNames列 [英] Propel case-sensitive phpNames for columns

查看:65
本文介绍了推进区分大小写的phpNames列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的schema.xml的相关部分:

<database name="Inventory" defaultIdMethod="native">
  <table name="Users" phpName="User">
    <column name="UserId" type="varchar" size="20" required="true" primaryKey="true" />
    <column name="FirstName" type="varchar" size="255" required="true" />
    <column name="LastName" type="varchar" size="255" required="true" />
    <column name="Password" type="varchar" size="255" required="true" />
    <column name="Salt" type="char" size="22" required="true" />
    <column name="RoleId" type="integer" required="true" />
    <column name="FailedLogins" type="integer" required="true" defaultValue="0" />
    <column name="LockedOut" type="boolean" required="true" defaultValue="false" />
    <column name="Active" type="boolean" required="true" defaultValue="true" />
  </table>
...
</database>

以下命令失败,并显示PropelException:

The following command fails with a PropelException:

UserQuery::create()
    ->filterByActive(true)
    ->update(array('FailedLogins' => 0, 'LockedOut' => false));

错误:

[Sat Nov 19 16:28:01 2011] [error] [client 127.0.0.11] PHP Fatal error:  Uncaught exception 'PropelException' with message 'Cannot fetch ColumnMap for undefined column phpName: FailedLogins' in /home/andrew/pss-repository/vendor/propel/runtime/lib/map/TableMap.php:372\nStack trace:\n#0 /home/andrew/pss-repository/vendor/propel/runtime/lib/query/ModelCriteria.php(1668): TableMap->getColumnByPhpName('FailedLogins')\n#1 /home/andrew/pss-repository/vendor/propel/runtime/lib/query/ModelCriteria.php(1626): ModelCriteria->doUpdate(Array, Object(PropelPDO), false)\n#2 /home/andrew/pss-repository/login-reset-process.php(11): ModelCriteria->update(Array)\n#3 {main}\n  thrown in /home/andrew/pss-repository/vendor/propel/runtime/lib/map/TableMap.php on line 372, referer: http://pss/login-reset-all.php

我能够验证在Propel生成的代码中FailedLogins列是否标识为Failedlogins.我意识到我可以将phpName添加到有问题的列中,但是我想知道是否错过了一个配置选项.我检查了推进构建时间配置页面,然后看到了一个名为propel.samePhpName的选项. ,但由于它位于逆向工程"部分下,因此似乎不是我需要的选项.其他人问过类似的问题,但我没有看到一个明确的答案.

I am able to verify that the FailedLogins column is identified as Failedlogins in the Propel-generated code. I realize that I can probably add phpName to the columns in question, but I was wondering if I have missed a configuration option. I checked the Propel buildtime configuration page, and I see an option called propel.samePhpName, but as it is under the "Reverse Engineering" section it does not appear to be the option I need. Others have asked similar questions, but I have not seen a clear answer.

是否有配置选项可以使每列的phpName与模式中的name属性简单匹配?

Is there a configuration option to make the phpName of each column simply match the name attribute in the schema?

推荐答案

没有办法做到这一点,也没有build属性.

No there is no way to do that, nor a build property.

实际上,您不应该像以前那样命名表属性,而应该对它们进行低估:

Actually, you should not name your table attributes like you did, you should underscorize them:

<table name="Users" phpName="User">
  <column name="user_id" type="varchar" size="20" required="true" primaryKey="true" />
  <column name="first_name" type="varchar" size="255" required="true" />
  <column name="last_name" type="varchar" size="255" required="true" />
  <column name="password" type="varchar" size="255" required="true" />
  <column name="salt" type="char" size="22" required="true" />
  <column name="role_id" type="integer" required="true" />
  <column name="failed_logins" type="integer" required="true" defaultValue="0" />
  <column name="locked_out" type="boolean" required="true" defaultValue="false" />
  <column name="active" type="boolean" required="true" defaultValue="true" />
</table>

这样,您将获得UserId,...,FailedLogins,...

That way you'll get UserId, …, FailedLogins, …

威廉

这篇关于推进区分大小写的phpNames列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆