2012年3月16日金曜日

3/12の訓練日誌

3/12の訓練日誌
1時間目・プログラミング実習
まずはBBSプロジェクトを作成する。
以下
//プロジェクトフォルダを作る

mkdir bbs2
cd bbs2
//プロジェクト作成
symfony init-project bbs2
//最初のアプリを作成

symfony init-app front
//最初のモジュールを作成
symfony init-module front default
//ルートになる
su -
//httpd.confを編集

vi /etc/httpd/conf/httpd.conf
httpd.confの最後に以下を追加
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ここから↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

<VirtualHost *:80>
    DocumentRoot /home/user/bbs2/web/
    ServerName www.bbs2.com
    ErrorLog logs/www.bbs2.com-error_log
    CustomLog logs/www.bbs2.com-access_log common
    <Directory "/home/tanaka/bbs2/web/">
        AllowOverride All
        Options -Includes -ExecCGI
    </Directory>
</VirtualHost>
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ここまで↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
//httpd再起動
/etc/init.d/httpd restart
//通常ユーザに戻る
exit
cd web
//シンボリックリンクを張る
 ln -s /usr/share/pear/data/symfony/web/sf/ ./sf

windowsのhostsファイルを変更する。
C:\WINDOWS\system32\drivers\etc\hostsに以下を追加
192.168.98.128 www.bbs2.com



2時間目・プログラミング実習
DB関連を作成
コメントテーブル作成

CREATE TABLE  comment (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `replycnt` int(11) NOT NULL DEFAULT '0',
  `nickname` text,
  `content` text,
  `url` text,
  `photo` text,
  `category_id` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `update_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
)COMMENT='コメント'
返信テーブル作成

CREATE TABLE  reply (
  id int(11) NOT NULL AUTO_INCREMENT,
  comment_id int(11) ,
  nickname text,
  content text,
  url text,
  photo text,
  created_at datetime DEFAULT NULL,
  update_at datetime DEFAULT NULL,
  delete_at datetime DEFAULT NULL,
  PRIMARY KEY (id)
)COMMENT='返信'
view.ymlを以下のように変更

  metas:
    title:        湘南BBS
    robots:       index, follow
    description:  求職者支援訓練で作成している掲示板です
    keywords:     求職者支援訓練, 掲示板, 湘南




3時間目・プログラミング実習
DB連動設定
propel.iniの以下2行を変更

propel.database.createUrl  = mysql://user:password@localhost/
propel.database.url        = mysql://user: password@localhost/bbs2


databases.yml

all:
  propel:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://user: password@localhost/bbs2
      encoding:     utf8
変更したらschema.ymlを生成
symfony propel-build-schema
続いてモデル生成
symfony propel-build-schema

defaultActionsクラスのexecuteIndexメソッドに(actions.class.php)
$this->comment = CommentPeer::retrieveByPk(1);
としてテンプレートに
<?php print_r($comment); ?>
と追加する


4時間目・プログラミング実習

defaultActionsクラスのexecuteIndexメソッドに(actions.class.php)
    $c = new Criteria;
    $this->comments = CommentPeer::doSelect($c);

としてテンプレートに
<?php print_r($comments); ?>
と追加する

テンプレートに


<table border="1">
<?php foreach($comments as $v): ?>
<tr>
<td>
<?php print $v->getId()?>
</td>
<td>
<?php print $v->getNickname()?>
</td>
<td>
<?php print nl2br($v->getContent())?>
</td>
<td>
<?php print $v->getUrl()?>
</td>
</tr>
<?php endforeach;?>
</table>


5時間目・プログラミング実習
職場見学
講師の方の事業内容とSEO対策

6時間目・プログラミング実習

0 件のコメント:

コメントを投稿