2012年2月15日水曜日

開発環境

  • OS X Lion - Apple(OS)
  • Apache (Web Server)
  • PHP (サーバーサイドプログラミング言語)
  • MySQL (データベース)
  • TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)

『初めてのPHP & MySQL 第2版』(Micbele E. Davis、Jon A. Phillips 著、西沢 直木 訳、オライリー・ジャパン、2008年、ISBN978-4-87311-365-4)の13章(データ構造とデータの変更)の問題1を解いてみる。

問13-1.

コード(TextWrangler)

<?php
  require_once('db_login.php');
  require_once('DB.php');
  $connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");
  if (DB::isError($connection)){
    die ("Could not connect to the database: <br />". DB::errorMessage($connection));
  }
  $query = "alter table books add published_date date";
  $result = $connection->query($query);
  if (DB::isError($result)){
    die(Could not query the database: <br />". $query. " " .DB::errorMessage($result));
  }
  echo "added sucessfully!<br />";
  $connection->discoonect();
?>

併せて読んでいる書籍。

0 コメント:

コメントを投稿