[Codeigniter-users] 簡単なモデルの利用

Back to archive index

牧尾竜一 ryuic****@jom*****
2008年 8月 5日 (火) 15:26:49 JST


JOMRです。

了解しました。
755→777に変更しました

>  kunitsujiです。
>
> とりあえずエラーの部分だけ
> Permission denied
> ということですので、
> system/cache/
> のパーミッションを変更してください。
>
>   
>> JOMRです。
>>
>> 少し長くなるのですが、
>> 検索メソッドをモデルを使って実装してみようと本を片手に
>>
>>
>> // 検索ページ
>> function search()
>> {
>> $q = ''; // 検索キーワード(検索用)
>> $q_disp = ''; // 検索キーワード(表示用)
>> $q_uri = ''; // 検索キーワード(URIセグメント用)
>>
>> $data['list'] = $this->Customer_model->get_cst_list();
>>
>> if ($this->input->post('q'))
>> {
>> $q = $this->input->post('q');
>> }
>> else
>> {
>> $q = $this->uri->segment(3, '');
>> }
>>
>> $offset = (int) $this->uri->segment(4, 0);
>> $q = trim(mb_convert_kana($q, "s"));
>>
>> if (strpos($q, '/') !== FALSE)
>> {
>> $q_disp = $q;
>> $q_uri = str_replace('/', '/', $q);
>> }
>>
>> else if ($q == '-' || $q == '')
>> {
>> $q = '';
>> $q_disp = '全商品';
>> $q_uri = '-';
>> }
>> else
>> {
>> $q_disp = $q;
>> $q_uri = $q;
>> }
>>
>> $data['list'] = $this->Customer_model->get_cst_by_search($q,
>> $this->limit, $offset);
>> $total = $this->Customer_model->get_cst_count_by_search($q);
>>
>> $path = '/customer/search/' . rawurlencode($q_uri);
>> $data['pagination'] = $this->_generate_pagination($path, $total, 4);
>>
>> $data['q'] = $q_disp;
>>
>> if ($total)
>> {
>> $data['total_item'] = $total . '社みつかりました。';
>> }
>> else
>> {
>> $data['total_item'] = '"'. $q_disp . '"の検索に一致する顧客存在しません。';
>> }
>>
>> $data['item_count'] = $this->Customer_model->get_cst_item_count();
>> $this->load->view('customer/search', $data);
>> }
>>
>> モデルには
>> function get_cst_by_search($q, $limit, $offset)
>> {
>> $keywords = explode(" ", $q);
>> foreach ($keywords as $keyword)
>> {
>> $this->db->like('cu_name', $keyword);
>> }
>> $this->db->order_by('cu_id');
>> $query = $this->db->get('customer', $limit, $offset);
>> return $query->result();
>> }
>>
>> function get_cst_count_by_search($q)
>> {
>> $this->db->select('cu_name');
>> $keywords = explode(" ", $q);
>> foreach ($keywords as $keyword)
>> {
>> $this->db->like('cu_name', $keyword);
>> }
>> $this->db->order_by('cu_id');
>> $query = $this->db->get('customer');
>> return $query->num_rows();
>> }
>>
>> function get_cst_item_count()
>> {
>> $cart = $this->get_cart();
>> return $cart['line'];
>> }
>>
>> とほぼ本のとおりに書いて
>> ビューには
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>> <link rel="stylesheet" href="<?=base_url();?>css/customer.css"
>> type="text/css" />
>> <title>顧客管理</title>
>> </head>
>> <body>
>>
>> <?=$this->load->view('parts/header');?>
>>
>> <!-- Content -->
>> <div id="content">
>>
>> <!-- body -->
>> <div id="body">
>> <h2>顧客検索メニュー</h2>
>>
>> <!-- box -->
>> <div class="box">
>> <p>ここに検索メニューが入る予定です</p>
>> <?=form_open('customer/search');?>
>>
>> <input type="text" name="q" value="" />
>> <input type="submit" class="search" value="検索" />
>> <?=form_close();?>
>> </div>
>> <!-- box END -->
>>
>> <h2>顧客一覧画面</h2>
>>
>> <!-- CustomerList -->
>> <div class="box">
>> <p>ここに顧客一覧が入る予定です</p>
>>
>> <table class="cstbl">
>> <tr>
>> <th class="cstd">ID</th>
>> <th class="cstd">顧客名</th>
>> <th class="cstd">連絡先</th>
>> <th class="cstd">登録日</th>
>> <th class="cstd">詳細</th>
>> </tr>
>>
>> <?php foreach($query->result() as $row): ?>
>> <tr>
>> <td class="cstd_List_No"><input type="hidden" name="cu_id"
>> value="<?=$row->cu_id?>" class="data" /><?=$row->cu_id?></td>
>> <td class="cstd_List_Name"><?=form_prep($row->cu_name);?></td>
>> <td class="cstd_List_Tel"><?=form_prep($row->cu_tel);?></td>
>> <td class="cstd_List_Date"><?=form_prep($row->datetime);?></td>
>> <td class="cstd_List_Detail">
>> <?=form_open('customer/detail/'. $row->cu_id);?>
>>
>> <input type="submit" value="確認" class="Confirm" />
>> <?=form_close();?></td>
>> </tr>
>> <?php endforeach; ?>
>>
>> </table>
>>
>> <?=$pagination?>
>>
>> </div>
>> <!-- CustomerList END -->
>>
>> </div>
>> <!-- body END -->
>>
>> <!-- explanation -->
>> <div id="explanation">
>> <div class="box">
>> <h3>顧客登録状況</h3>
>> <p>登録されている顧客数は<br /><?=form_prep($cst_item);?></p>
>> </div>
>> <div class="box">
>> <h3>操作パネル</h3>
>> <ul>
>> <li><a href="<?=$this->config->site_url();?>customer/post">顧客新規登録
>> </a></li>
>> </ul>
>> </div>
>> </div>
>> <!-- explanation END -->
>>
>> </div>
>> <!-- Content END-->
>>
>>
>> <?=$this->load->view('parts/footer');?>
>>
>> としまして、検索を実行すると真っ白のページになってしまいます。
>> 検索キーは顧客名で行い、customer/search.phpでは検索結果を表示させたいと
>> 思っています。
>> エラーなどが表示されないのでどこを見たらいいのかわかりません。
>> 検索結果のページには
>>
>> <div class="shop_title">「<?=form_prep($q);?>」の検索結果</div>
>>
>> <?=$pagination?>
>>
>> <p class="coment"><?=$total_item?></p>
>>
>> <?php foreach($list as $row): ?>
>> <a href="<?=base_url();?>customer/<?=$row->cu_id?>">
>> 詳細
>> </a>
>> <p class="shop_list">
>> <?=anchor('customer/detail' . $row->cu_id, $row->cu_name);?> <br />
>> TEl: <?=number_format($row->cu_tel);?><br />
>>
>> </p>
>> <hr />
>> <?php endforeach; ?>
>>
>> <?=$pagination?>
>>
>> とりあえずこのように記述しています。
>> ちなみにエラーログをみると
>> ERROR - 2008-08-05 15:06:59 --> Severity: Warning -->
>> fopen(/home/local/ci.jom.local/system/cache/9bf31c7ff062936a96d3c8bd1f8f2ff3)
>> [<a href='function.fopen'>function.fopen</a>]: failed to open stream:
>> Permission denied /home/local/ci.jom.local/system/codeigniter/Common.php 49
>> というものが大量にかかれていました。
>> このエラーはこの真っ白になるページとなにか関係があるのでしょうか?
>>
>>
>>     
>>> JOMRです。
>>> 少し日が空いてしまいましたが、
>>> 検索キーについてなのですが、顧客名、連絡先で検索できるようにしたいです。
>>> これもモデルをつかうのでしょうか?
>>>
>>>
>>>   
>>>       
>>>> リクエスト>
>>>> 	ログインチェック
>>>> 		なしの場合はログイン画面へ
>>>> 	デフォルトページは顧客一覧画面
>>>> 		10件から15件の顧客一覧表示
>>>> 		検索窓を用意する
>>>> 		?検索キーは何にするのか?
>>>> 		顧客ID、顧客名から詳細画面へのリンク
>>>> 		新規顧客登録処理へのリンク
>>>> 		ログアウト
>>>> 	顧客詳細画面
>>>> 		顧客個別のデータを表示する
>>>> 		顧客別にPCデータ、障害訪問履歴がある場合は表示する
>>>> 		編集、削除処理へ
>>>> 		一覧画面へ
>>>> 	新規顧客登録画面
>>>> 		顧客情報を登録する
>>>> 		顧客一覧へ
>>>> 	新規顧客登録の確認画面
>>>> 		登録画面で入力した内容を表示する
>>>> 		登録処理、戻る処理
>>>> 	顧客情報編集画面
>>>> 		顧客IDを元に、データを編集する画面
>>>> 		顧客一覧へ
>>>> 	顧客情報編集の確認画面
>>>> 		編集画面で入力した内容を表示する
>>>> 		登録処理、戻る処理
>>>> 	PC情報登録ページ
>>>> 		顧客詳細から、顧客のPCデータとして保存する
>>>> 		顧客情報へ戻る
>>>> 	PC情報登録の確認画面
>>>> 		入力内容を表示
>>>> 		登録する、戻る
>>>> 	PC詳細画面
>>>> 		顧客詳細から顧客IDに関連づけられたPCデータを表示する
>>>> 		一覧(詳細)表示
>>>> 		障害履歴
>>>> 		対応方法などを表示
>>>> 		編集、削除へのリンク
>>>> 		顧客詳細へ戻る
>>>> 	PC編集画面
>>>> 		PC詳細から開く
>>>> 		内容を編集する
>>>> 	PC編集の確認画面
>>>> 		入力内容を表示する
>>>> 		登録、戻る
>>>>
>>>> 画面としてはこんな感じでしょうかね?
>>>> では、これをPPTか何かでずにしてみますね。
>>>> そこに関連するテーブルをひもづけていけば、大体の概要がわかるかなとおもい
>>>> ます。
>>>>
>>>> _______________________________________________
>>>> Codeigniter-users mailing list
>>>> Codei****@lists*****
>>>> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>>>>
>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG - http://www.grisoft.jp 
>>>> Version: 8.0.138 / Virus Database: 270.5.5/1569 - Release Date: 2008/07/23 
>>>> 13:31
>>>>
>>>>
>>>>
>>>>   
>>>>     
>>>>         
>>> _______________________________________________
>>> Codeigniter-users mailing list
>>> Codei****@lists*****
>>> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>>>
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG - http://www.grisoft.jp 
>>> Version: 8.0.138 / Virus Database: 270.5.6/1576 - Release Date: 2008/07/27 
>>> 16:16
>>>
>>>
>>>
>>>   
>>>       
>> _______________________________________________
>> Codeigniter-users mailing list
>> Codei****@lists*****
>> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>>     
>
> _______________________________________________
> Codeigniter-users mailing list
> Codei****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.grisoft.jp 
> Version: 8.0.138 / Virus Database: 270.5.12/1591 - Release Date: 2008/08/04 19:23
>
>
>
>   




Codeigniter-users メーリングリストの案内
Back to archive index