2013-11-25 105 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