intro
以前に作成した追加/更新/削除/閲覧コントローラを複数ページフォーム対応にしてみます。ただし、リレーションは1:1のみ対応です。
1.コントローラの作成
以下のように
library/My/Controller/MultiPage.php
ファイルを作成します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">'My/Controller/Simple.php'</span>; <span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">'My/Form/MultiPage.php'</span>; <span style="color: #b1b100;">require_once</span> <span style="color: #ff0000;">'Zend/Session/Namespace.php'</span>; <span style="color: #000000; font-weight: bold;">class</span> My_Controller_MultiPage <span style="color: #000000; font-weight: bold;">extends</span> My_Controller_Simple <span style="color: #66cc66;">{</span> protected <span style="color: #0000ff;">$_session_name</span> = <span style="color: #ff0000;">'my_controller_multipage'</span>; protected <span style="color: #0000ff;">$_table_form_classes</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; protected <span style="color: #0000ff;">$_form</span> = <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getForm<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #0000ff;">$this</span>->_form<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$form</span> = <span style="color: #000000; font-weight: bold;">new</span> My_Form_MultiPage<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_session_name<span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_table_form_classes <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$table_class</span> => <span style="color: #0000ff;">$form_class</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">addForm</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_class</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0000ff;">$form_class</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #0000ff;">$this</span>->_form = <span style="color: #0000ff;">$form</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$this</span>->_form; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> prepareForm<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$form</span>, <span style="color: #0000ff;">$label</span>, <span style="color: #0000ff;">$back</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><a href="http://www.php.net/method_exists"><span style="color: #000066;">method_exists</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$form</span>, <span style="color: #ff0000;">'prepareForm'</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">prepareForm</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_getFormActionUrl<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, <span style="color: #0000ff;">$label</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">return</span> parent::<span style="color: #006600;">prepareForm</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$form</span>, <span style="color: #0000ff;">$label</span>, <span style="color: #0000ff;">$back</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTable<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #0000ff;">$this</span>->_form<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$this</span>->_form = <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">getForm</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #0000ff;">$table_class</span> = <span style="color: #0000ff;">$this</span>->_form-><span style="color: #006600;">getCurrentFormName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_class</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0000ff;">$table_class</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _clearSession<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> parent::_clearSession<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">getForm</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>-><span style="color: #006600;">clear</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _handleNextEvent<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$session</span> = <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">getSession</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$form</span> = <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">getForm</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$action_label</span> = <span style="color: #0000ff;">$this</span>->_request-><span style="color: #006600;">getActionName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$form</span>-><span style="color: #006600;">isValid</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$form</span>-><span style="color: #006600;">isConfirm</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">view</span>-><span style="color: #006600;">values</span> = <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">getValues</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">view</span>-><span style="color: #006600;">form</span> = <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">prepareForm</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_getFormActionUrl<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, <span style="color: #0000ff;">$action_label</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">'detail'</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">view</span>-><span style="color: #006600;">title</span> = <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">getCurrentFormName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">view</span>-><span style="color: #006600;">form</span> = <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">prepareForm</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_getFormActionUrl<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, <span style="color: #0000ff;">$action_label</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">'form'</span>; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _handleBackEvent<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$form</span> = <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">getForm</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">back</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$this</span>-><span style="color: #006600;">view</span>-><span style="color: #006600;">form</span> = <span style="color: #0000ff;">$form</span>-><span style="color: #006600;">prepareForm</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_getFormActionUrl<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>, <span style="color: #ff0000;">'next'</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">'form'</span>; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _executeFind<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, &<span style="color: #0000ff;">$id</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$table</span>-><span style="color: #006600;">find</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$id</span><span style="color: #66cc66;">)</span>-><span style="color: #006600;">current</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$id</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$this</span>->_getValues<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span>, <span style="color: #0000ff;">$id</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _executeInsert<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, <span style="color: #0000ff;">$values</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$dependant</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$values</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$table_name</span> => <span style="color: #0000ff;">$table_values</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$table</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0000ff;">$table_name</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$dependant</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$this</span>->_makeReference<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, <span style="color: #0000ff;">$prev_table</span>, <span style="color: #0000ff;">$prev_id</span>, <span style="color: #0000ff;">$table_values</span>, <span style="color: #0000ff;">$prev_values</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #0000ff;">$prev_id</span> = <span style="color: #0000ff;">$table</span>-><span style="color: #006600;">insert</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_values</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$prev_table</span> = <span style="color: #0000ff;">$table_name</span>; <span style="color: #0000ff;">$prev_values</span> = <span style="color: #0000ff;">$table_values</span>; <span style="color: #0000ff;">$dependant</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _executeUpdate<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, <span style="color: #0000ff;">$id</span>, <span style="color: #0000ff;">$values</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$dependant</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$values</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$table_name</span> => <span style="color: #0000ff;">$table_values</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$table</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0000ff;">$table_name</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$current_id</span> = <span style="color: #0000ff;">$id</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$table_name</span><span style="color: #66cc66;">]</span>; <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$table</span>-><span style="color: #006600;">find</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$current_id</span><span style="color: #66cc66;">)</span>-><span style="color: #006600;">current</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>!<span style="color: #0000ff;">$row</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$this</span>->_makeReference<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, <span style="color: #0000ff;">$prev_table</span>, <span style="color: #0000ff;">$prev_id</span>, <span style="color: #0000ff;">$table_values</span>, <span style="color: #0000ff;">$prev_values</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$table</span>-><span style="color: #006600;">createRow</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #0000ff;">$row</span>-><span style="color: #006600;">setFromArray</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_values</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$row</span>-><span style="color: #006600;">save</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$prev_id</span> = <span style="color: #0000ff;">$current_id</span>; <span style="color: #0000ff;">$prev_table</span> = <span style="color: #0000ff;">$table_name</span>; <span style="color: #0000ff;">$prev_values</span> = <span style="color: #0000ff;">$table_values</span>; <span style="color: #0000ff;">$dependant</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _executeDelete<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, <span style="color: #0000ff;">$id</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$id</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$table_name</span> => <span style="color: #0000ff;">$current_id</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$table</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0000ff;">$table_name</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$table</span>-><span style="color: #006600;">find</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$current_id</span><span style="color: #66cc66;">)</span>-><span style="color: #006600;">current</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$row</span>-><span style="color: #006600;">delete</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _getValues<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span>, &<span style="color: #0000ff;">$ids</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$values</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$ids</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$dependant</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$this</span>->_table_form_classes <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$table_class</span> => <span style="color: #0000ff;">$form_name</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$depandant</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$row</span>-><span style="color: #006600;">findDependentRowset</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_class</span><span style="color: #66cc66;">)</span>-><span style="color: #006600;">current</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$values</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$table_class</span><span style="color: #66cc66;">]</span> = <span style="color: #0000ff;">$row</span>-><span style="color: #006600;">toArray</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$ids</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$table_class</span><span style="color: #66cc66;">]</span> = <span style="color: #0000ff;">$this</span>->_getRowId<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_class</span>, <span style="color: #0000ff;">$row</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$depandant</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$depandant</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$values</span>; <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _makeReference<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table</span>, <span style="color: #0000ff;">$ref_table_name</span>, <span style="color: #0000ff;">$ref_row_id</span>, &<span style="color: #0000ff;">$values</span>, &<span style="color: #0000ff;">$ref_values</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$referenceMap</span> = <span style="color: #0000ff;">$table</span>-><span style="color: #006600;">getReference</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$ref_table_name</span><span style="color: #66cc66;">)</span>; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">(</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$i</span> < <a href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$referenceMap</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'columns'</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">)</span>; <span style="color: #0000ff;">$i</span>++<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$column</span> = <span style="color: #0000ff;">$referenceMap</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'columns'</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">]</span>; <span style="color: #0000ff;">$ref_column</span> = <span style="color: #0000ff;">$referenceMap</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'ref_columns'</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">]</span>; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$ref_values</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$ref_column</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$values</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$column</span><span style="color: #66cc66;">]</span> = <span style="color: #0000ff;">$ref_values</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$ref_column</span><span style="color: #66cc66;">]</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">{</span> <span style="color: #0000ff;">$values</span><span style="color: #66cc66;">[</span><span style="color: #0000ff;">$column</span><span style="color: #66cc66;">]</span> = <span style="color: #0000ff;">$ref_row_id</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> protected <span style="color: #000000; font-weight: bold;">function</span> _getRowId<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$table_class</span>, <span style="color: #0000ff;">$row</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span>-><span style="color: #006600;">id</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$row</span>-><span style="color: #006600;">id</span>; <span style="color: #66cc66;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> |
次回
作成したコントローラを使います。
履歴
日付 | 内容 |
---|---|
2008/4/20 | 公開 |
2008/4/26 | My_Form_MultiPageの修正に伴いコントローラを修正しました。 |