はじめに PHP界隈では現在、PHP 4からPHP 5への移行が進んできており、ここ最近ではPHP 5の機能を活用したフレームワークも多く出てくるようになりました。 PHP 5は、PHP 4に比べオブジェクト指向のサポートや速度面での向上などが取り上げられる中、最も注目すべき点であるデータベースへのアクセスを抽象化したレイヤーとしてPDOが登場しました。 今回はそのPDOに注目し、サンプルを交えてPDOの使い方を紹介します。 対象読者 PHP 5を使ったことがある方 以前PEAR::DBなどを用いてデータベースを使ったアプリケーションを作成したことのある方 必要な環境 PDOはPHP 5.1から標準で導入されるようになりました。Windows/UNIXを問わず利用することができます。よってPHP 5.1の環境と、PDOの動作に必要なデータベースの構築を行ってください。 PDOとは PDO(
さて夏がやってきました。夏と言えばPHPということで、昨年に引き続き、最近のPHP事情をご紹介。 1. PHP5.4リリース PHP5.4が2012年3月にリリースされました。 Traits や Short array syntax(配列の短縮構文)、array dereferencing(foo()[0]) などのPHP言語拡張、PHPコマンドで起動するビルトインサーバ、そしてパフォーマンスの改善など大きな変更が加えられています。 言語自体の機能追加も注目ですが、ビルトインサーバは多くの人にとってメリットになるでしょう。これを使えばPHPアプリケーションの動作確認のためにApacheやnginxなどのhttpdサーバを自分のPCに入れる必要はありません。 下記のようなコマンドを打つだけで、ビルトインサーバが起動します。新しいフレームワークやライブラリ、アプリケーションを試してみたい時に手
PHPによるデザインパターン入門 秀和システムから発売となった「PHPによるデザインパターン入門」(ISBN4-7980-1516-4・ 2006/11/23発売)を執筆しました(共著です)。 「PHPを使ってGoFパターンを見ていこう」的な書籍になっています。GoFパターンについては、それぞれパターンの説明とサンプルコードという構成です。サンプルコードは、CentOS4.4/Windows XP(SP2)+PHP5.1.x/5.2.0で動作確認しています。 目次は以下の通りです。 1章 デザインパターンの世界へようこそ デザインパターンって何? デザインパターンとは? オブジェクト指向 GoFパターン デザインパターンのメリット・デメリット デザインパターンを使うメリット デザインパターンを使うデメリット PHPとオブジェクト指向 PHPとは? PHP5でのオブジェクト指向開発 2章
オリジナルはココです。フェイスブックのエンジニアでで史上ベスト3に入るといわれるEvan Priestley氏への質問「どうやってプログラミングを覚えましたか」に対する本人からの答えです。 手短かに言えば 何年もの歳月の賜物というか。ぼくはただひたすらプログラミングが大好きで、(フェイスブックで働いていた)過去4年間、ほとんど他のことをしていない。その前も2.5年ほどプログラマーとして働いていたし、そのさらに前も6年くらい趣味でプログラミングをしていた。ぼくは高校も大学も中退しているので、それで空いた時間もプログラミングに費やした。つい最近フェイスブックを辞めたけど、未だに起きている時間のほとんどはプログラミングだ。 もっと詳しく言えば 月並みだが、ぼくはちっちゃい頃からコンピューターが好きで、我が家にあったヤツで(最初はMac Plusで途中からIIsiになった)で散々遊んだ。8歳か9歳
PHPの実行環境をPaaS型クラウドとして提供している「PHP fog」はブログで、いままで6カ月だった無料サービスの利用期間を、永久に無料のままにすると発表しました。しかも3つのアプリケーションまで無料にするとのこと。 もちろん無料で使えるリソースの範囲はそれほど大きくありませんが、PHPアプリケーションを自由にデプロイできるため、例えばWordpressを入れて自由にブログを運営する、といったことができるはず。 実はPHP fogだけでなくPaaS型クラウドでは無料でずっと利用できるコースを設定しているサービスがいくつもあります。この機会にまとめてみました。 PHP fog まずはそのPHP fog。名前の通りPHPの実行環境をクラウド上で提供します。MySQLデータベースもあらかじめ用意されており、WordPress、Drupal、Sugar CRM、Joomlaといった有名どころの
ここでは、プログラミングを習い始める段階で、よく最初の課題などにされる 平均値、分散、標準偏差を求める PHP のサンプルコードを示す。 関連 VB や C# で平均、分散、標準偏差を求めるサンプルコード [PHP]class calc { /* * 平均値を求める */ public static function average(array $values) { return (float) (array_sum($values) / count($values)); } /* * 分散を求める * 分散 =((データ-平均値)の2乗)の総和 ÷ 個数 */ public static function variance(array $values) { // 平均値を求める $ave = self::average($values); $variance = 0.0; foreach
こころが満たされる日々の生活をサポート!韓国雑貨のセレクトショップ『#ていねいな暮らし』が正式オープン! 2021年10月7日
2008/2/12:「公開APIを利用したサンプルサイトを作っていくよ」は、書籍発売に伴い、新サイトに移転しました。 →公開APIを利用したサンプルサイトを作っていくよ 新サイトでは、サンプルサイトの他に、サンプルソースコードの掲載もしていく予定です。 旧サイト(このページは)、削除せずにこのまま残しておきますので、新旧サイトともに今後ともご利用ください。 (旧)公開APIを利用したサンプルサイトを作っていくよ TOP ABOUT BOOK LINK MAIL BLOG 本館 ZAPAnet総合情報局管理人ZAPAが公開API(Webサービス)を利用して、サンプルサイトを作って紹介しています。 Web2.0、マッシュアップの流行によってせっかくWeb上でAPIが公開されていても、利用する前に規約に同意して、開発用ドキュメント(HTMLからPDF、EXECL、WORDなどドキュメントのフォー
MVC 設計について考えていたときに、ちょうどその辺りの話をされている方々が居たので、今の考えをまとめてみました。 目次 前提 肥大化するコントローラを避ける ビジネスロジックをどこに書けば良いのか コントローラとモデルの間にもう一つの層があるとうまくいく? まとめ 前提対象は Web アプリケーションで、画面数(ビューの数)は数個〜100個程度の規模です。WordPress、Twitter、37signals のサービスのようなものを作ろうとするとき、どういう MVC 設計をしていくかについて考えます。巨大なシステム、金融系システム、基幹系システムなどを作る場合とは異なる考え方もあると思います(そもそも MVC を使わない、など)。 肥大化するコントローラを避ける例えば、八百屋さんで「60円で仕入れたリンゴ1つを100円で売った」こと(Sales Transaction)を記録する場合を
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く