2012-01-11 7 views
0

Xmlを使用してデータベースのテーブルと構造を動的に作成する方法はありますか?CakephpでXMLを使用してデータベースのテーブルと構造を自動的に作成する方法

Xmlを参照として列を生成するようにします。

Cakephpで利用できるものは何ですか?以下は

私が使用する予定のサンプルXMLである:(私はそれがかなり大きいほど、それらのすべてをコピー&ペーストしませんでした)

</dsr_data_agg_stats> 
     <state code="ACT"> 
     <post_code code="2600"> 
      <locality name="DEAKIN"> 
      <dwelling_type code="H"> 
       <typical_value rank="3341/3697">831000</typical_value> 
       <dom score="1" rank="454/5673">56</dom> 
       <discount score="0" rank="779/5673">5%</discount> 
       <acr score="-1" rank="914/5531">59%</acr> 
       <renters score="0" rank="5131/5627">42%</renters> 
       <vacancy score="1" rank="4714/5673">2.61%</vacancy> 
       <yield score="-1" rank="678/3697">3.69%</yield> 
       <som score="1" rank="3915/5144">2.08%</som> 
       <search_dsr score="-3" rank="3578/4009">4.9</search_dsr> 
       <dsr rank="3121/5673">23</dsr> 
       <sr rank="2552/5673">5.8</sr> 
      </dwelling_type> 
      </locality> 
      <locality name="YARRALUMLA"> 
      <dwelling_type code="H"> 
       <typical_value rank="3438/3697">931250</typical_value> 
       <dom score="1" rank="454/5673">56</dom> 
       <discount score="0" rank="779/5673">5%</discount> 
       <acr score="-2" rank="1999/5531">42%</acr> 
       <renters score="0" rank="5131/5627">42%</renters> 
       <vacancy score="1" rank="4714/5673">2.61%</vacancy> 
       <yield score="1" rank="678/3697">4.76%</yield> 
       <som score="0" rank="4333/5144">3.03%</som> 
       <search_dsr score="-3" rank="3277/4009">7</search_dsr> 
       <dsr rank="3121/5673">23</dsr> 
       <sr rank="2552/5673">5.8</sr> 
      </dwelling_type> 

...

答えて

0

私がやってに取り組んでいます似たようなものだが、RSSフィードがある。私は実際にredisの構文が好きであることがわかりました。これは複雑で堅牢な構造のボキャブラリを好きなように使用できますが、ハッシュ地図。さまざまな言語のトンで非常に使いやすいクライアントがありますが、以下のような文字列パターンをパターン 'アクション' 'キー'の値で確実に見つける方法について考えています」、$が与えられた文字列のvariabeコンポーネントを表す:

私はRedisのと直接対話し、どのルートサーバ側のインターフェイスにjQueryの$ .postの非同期相互作用を介して、クライアント側の呼び出しを行うためにPHPを使用し
get locality:$id = name 
list locality:dwellings = [dwelling:id, dwelling:id ...] 
map-get dwelling:id 'typical_value' = 'rank: $rank\tvalue: $value' 

redisアクセサクラスへのコマンド。インターフェイスはかなりシンプルです。ここにjQueryの側面があります。

/*QUERY 
*functional programming puts a big emphasis on "wrapping" repetitive tasks inside 
*another function. This one amounts to the same thing as a protocol in 
*Clojure, with the query map acting as the dispatch value that triggers 
*the right method on the server side, recieves and parses the response, 
*and then passes it on to the "body" of the client logic expressed in callback, 
*which causes side effects on the screen. 
*/ 
redgets.query = function(query_map, callback) { 
    $.post(redgets.router, query_map, function(data) { 
    return callback($.parseJSON(data)); 
    }); 
}; 

と例のquery_mapは、次のようになります。)

$response = array(); 
switch ($_POST['method']) { 
case 'locality_by_id': 
    if ($_POST['localityID']) { 
     $response = $this->locality_by_id($_POST['localityID']); 
     break; 
//etc, until 
return json_encode($response); 
} 

ます$ this-> locality_by_id(です:

例えばPHPルータはと解釈することができ
{method: 'locality_by_id', localityID: 'locality:1'} 

predisクライアントインターフェイスを使用して再送信するクエリです。

Redisは、フラットマップ上にツリーデータ構造をレイアウトすることで頭を包み込むと、XMLファイルのランダムアクセスがずっと速く簡単になります。つまり、DOMアイテムを再分かりやすいキーと値のペアに変換するパーサーを作成する必要があります。私はあなたがこれを行う最善の方法についていくつかのアイデアを持っていると確信しています。そして、いったんコンバータを書いたら、その逆をするのは簡単でしょう。

(私はリンクを追加しますが、迷惑メール制御sez no)