Upgrade to Pro — share decks privately, control downloads, hide ads and more …

8時間耐久CakePHP2勉強会@福岡

Yusuke Ando
February 13, 2012

 8時間耐久CakePHP2勉強会@福岡

8時間耐久CakePHP2勉強会の福岡での資料です。

Yusuke Ando

February 13, 2012
Tweet

More Decks by Yusuke Ando

Other Decks in Programming

Transcript

  1. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP <?php $keyword = ''; if (isset($_POST['keyword'])) { $keyword

    = $_POST['keyword']; } mysql_connect('localhost','user','password'); mysql_select_db('cakephp_sample'); mysql_query('set names utf8'); $sql = sprintf( "SELECT id,name,description FROM friends WHERE name LIKE '%s'", mysql_real_escape_string('%'.$keyword.'%') ); $result = mysql_query($sql); $data = array(); while ($row = mysql_fetch_assoc($result)) { $data[] = $row; } ?> <html> <head><title>ςετϖʔδ</title></head> <body> <form action="list1.php" method="POST"> <input name="keyword"><input type="submit"> </form> <ul> <?php foreach ($data as $row) { echo '<li>'; echo $row['name']; echo $row['description']; echo '</li>'; } ?></ul> </body></html>
  2. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP <?php $keyword = ''; if (isset($_POST['keyword'])) { $keyword

    = $_POST['keyword']; } mysql_connect('localhost','user','password'); mysql_select_db('cakephp_sample'); mysql_query('set names utf8'); $sql = sprintf( "SELECT id,name,description FROM friends WHERE name LIKE '%s'", mysql_real_escape_string('%'.$keyword.'%') ); $result = mysql_query($sql); $data = array(); while ($row = mysql_fetch_assoc($result)) { $data[] = $row; } ?> <html> <head><title>ςετϖʔδ</title></head> <body> <form action="list1.php" method="POST"> <input name="keyword"><input type="submit"> </form> <ul> <?php foreach ($data as $row) { echo '<li>'; echo $row['name']; echo $row['description']; echo '</li>'; } ?></ul> </body></html> 7JFX΁ .PEFM΁
  3. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP <?php //index.php $keyword = ''; if (isset($_POST['keyword'])) {

    $keyword = $_POST['keyword']; } include ‘model.php’; include ‘view.php’; <?php //model.php mysql_connect('localhost','user','password'); mysql_select_db('cakephp_sample'); mysql_query('set names utf8'); $sql = sprintf( "SELECT id,name,description FROM friends WHERE name LIKE '%s'", mysql_real_escape_string('%'.$keyword.'%') ); $result = mysql_query($sql); $data = array(); while ($row = mysql_fetch_assoc($result)) { $data[] = $row; } <!-- view.php --> <html> <head><title>ςετϖʔδ</title></head> <body> <form action="list1.php" method="POST"> <input name="keyword"><input type="submit"> </form> <ul> <?php foreach ($data as $row) { echo '<li>'; echo $row['name']; echo $row['description']; echo '</li>'; } ?></ul> </body></html> .PEFM 7JFX $POUSPMMFS
  4. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP SFXSJUFແ͠ͷ৔߹ /** * To configure CakePHP *not* to

    use mod_rewrite and to * use CakePHP pretty URLs, remove these .htaccess * files: * * /.htaccess * /app/.htaccess * /app/webroot/.htaccess * * And uncomment the App.baseUrl below: */ //Configure::write('App.baseUrl', env('SCRIPT_NAME')); ίϝϯτΛ֎͢ SFXSJUF͕ແཧͳ͚࣌ͩ VSMͷ຤ඌʹJOEFYQIQΛ෇͚Δ
  5. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP యܕతͳίϯτϩʔϥʔ  QIQ BQQ$POUSPMMFS5BTLT$POUSPMMFSQIQ "QQVTFT "QQ$POUSPMMFS $POUSPMMFS 

    DMBTT5BTLT$POUSPMMFSFYUFOET"QQ$POUSPMMFS\ QVCMJDGVODUJPOJOEFY \ UBTL@EBUBUIJT5BTLpOE bBMM`  UIJTTFU bUBTL@EBUB` UBTL@EBUB  ^ ^
  6. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP UIJTpOE bBMM` PQUJPOT  UIJTpOE bpSTU` PQUJPOT 

    UIJTpOE bDPVOU` PQUJPOT  UIJTpOE bMJTU` PQUJPOT  UIJTpOE bUISFBEFE` PQUJPOT  UI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UFS     QIQFDIPUIJT)UNMMJOL UIJT)UNMJNBHF DBLFQPXFSHJG      IUUQXXXDBLFQIQPSH     EJW  EJW   QIQFDIPUIJTFMFNFOU TRM@EVNQ   CPEZ
  11. ࣌ؒ଱ٱ$BLF1)1!෱Ԭ:VTVLF"OEP !ZBOEP $44ͳͲ IFBE   QIQFDIPUIJT)UNMDIBSTFU   

    UJUMF    QIQFDIPDBLF%FTDSJQUJPO     QIQFDIPUJUMF@GPS@MBZPVU   UJUMF   QIQ   FDIPUIJT)UNMNFUB JDPO    FDIPUIJT)UNMDTT DBLFHFOFSJD    FDIPTDSJQUT@GPS@MBZPVU   IFBE