2013-11-25 42 views
0

我从来不喜欢SQL,很高兴找到Propel。推动产生错误

我 “的schema.xml” 看起来如下:

<?xml version="1.0" encoding="UTF-8"?> 
<database name="lifeplan" defaultIdMethod="native"> 
    <table name="event" phpName="Event"> 
     <column name="event_id" type="integer" size="11" required="true" primaryKey="true" autoIncrement="true" /> 
     <column name="event_title" type="varchar" size="80" default="null" /> 
     <column name="event_desc" type="text"/> 
     <column name="event_start" type="timestamp" required="true" default="0000-00-00 00:00:00" /> 
     <column name="event_end" type="timestamp" required="true" default="0000-00-00 00:00:00" /> 
     <index name="event_start"> 
      <index-column name="event_start" /> 
     </index> 
    </table> 
</database> 

我正确地组织索引列?

build.properties:

propel.database = pgsql 
propel.project = lifeplan 

运行propel-gen后的第一个错误:

propel > sql: 

    [echo] +------------------------------------------+ 
    [echo] |           | 
    [echo] | Generating SQL for YOUR Propel project! | 
    [echo] |           | 
    [echo] +------------------------------------------+ 
[phingcall] Calling Buildfile 'C:\php\propel\generator\build-propel.xml' with ta 
rget 'sql-template' 
[property] Loading C:\php\propel\generator\.\default.properties 

propel > sql-template: 

[propel-sql] Loading XML schema files... 
Execution of target "sql-template" failed for the following reason: Error settin 
g up column 'event_desc': Cannot map unknown Propel type 'TEXT' to native databa 
se type. 
[phingcall] Error setting up column 'event_desc': Cannot map unknown Propel type 
'TEXT' to native database type. 
Execution of target "sql" failed for the following reason: Execution of the targ 
et buildfile failed. Aborting. 
[phingcall] Execution of the target buildfile failed. Aborting. 
Execution of target "main" failed for the following reason: Execution of the tar 
get buildfile failed. Aborting. 
    [phing] Execution of the target buildfile failed. Aborting. 

我改变BLOB TEXT和得到:

propel > om: 

    [echo] +------------------------------------------+ 
    [echo] |           | 
    [echo] | Generating Peer-based Object Model for | 
    [echo] | YOUR Propel project!      | 
    [echo] |           | 
    [echo] +------------------------------------------+ 
[phingcall] Calling Buildfile 'C:\php\propel\generator\build-propel.xml' with ta 
rget 'om-template' 
[property] Loading C:\php\propel\generator\.\default.properties 

propel > om-template: 

[propel-om] Loading XML schema files... 
[propel-om] 1 tables found in 1 schema files. 
[propel-om] Generating PHP files... 
Execution of target "om-template" failed for the following reason: Unable to par 
se default temporal value "'0000-00-00 00:00:00'" for column "event.event_start" 
[wrapped: DateTime::__construct(): It is not safe to rely on the system's timez 
one settings. You are *required* to use the date.timezone setting or the date_de 
fault_timezone_set() function. In case you used any of those methods and you are 
still getting this warning, you most likely misspelled the timezone identifier. 
We selected the timezone 'UTC' for now, but please set date.timezone to select 
your timezone.] 
[phingcall] Unable to parse default temporal value "'0000-00-00 00:00:00'" for c 
olumn "event.event_start" [wrapped: DateTime::__construct(): It is not safe to r 
ely on the system's timezone settings. You are *required* to use the date.timezo 
ne setting or the date_default_timezone_set() function. In case you used any of 
those methods and you are still getting this warning, you most likely misspelled 
the timezone identifier. We selected the timezone 'UTC' for now, but please set 
date.timezone to select your timezone.] 
Execution of target "om" failed for the following reason: Execution of the targe 
t buildfile failed. Aborting. 
[phingcall] Execution of the target buildfile failed. Aborting. 
Execution of target "main" failed for the following reason: Execution of the tar 
get buildfile failed. Aborting. 
    [phing] Execution of the target buildfile failed. Aborting. 

删除默认值第三次,我得到了一些已经无法应付的东西:

propel > convert-conf: 

    [echo] +------------------------------------------+ 
    [echo] |           | 
    [echo] | Converting runtime config file to an  | 
    [echo] | array dump for improved performance.  | 
    [echo] |           | 
    [echo] +------------------------------------------+ 
Execution of target "convert-conf" failed for the following reason: C:\php\prope 
l\generator\build-propel.xml:575:20: C:\php\propel\generator\build-propel.xml:57 
5:20: No valid xmlConfFile specified. 
[phingcall] C:\php\propel\generator\build-propel.xml:575:20: C:\php\propel\gener 
ator\build-propel.xml:575:20: No valid xmlConfFile specified. 
Execution of target "main" failed for the following reason: Execution of the tar 
get buildfile failed. Aborting. 
    [phing] Execution of the target buildfile failed. Aborting. 

有没有解决我的问题?

回答

4

有两个初始的问题,都容易解决:

  • default="0000-00-00 00:00:00"是无效的日期,并正确不允许。最好关掉required并改用null。
  • 正如错误消息所述,您需要在您的php.ini中设置date.timezone

至于你的类型错误,请尝试使用“longvarchar”而不是“text”。请参阅supported types here