PHP逆引き大全 516の極意

データベースの極意 - Tips407 抽出結果を連想配列で取得する

登録タグ
PHP
Icon comment count 0
Icon stock count 0

6-4Propelの利用 基本編Tips407 抽出結果を連想配列で取得する

Level2

PointフォーマッターとしてPropelArrayFormatterを指定する

抽出結果を連想配列で取得するには、ModelCriteria::setFormatter()を利用し、引数にPropelArrayFormatterを使用します。

リスト1407.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>結果セットを配列で取得する</title>
</head>
<body>
<?php
require_once('config.inc.php');
$books = BookQuery::create()
  ->setFormatter('PropelArrayFormatter')
  ->find();
echo '<table border="1">';
foreach($books as $book){
    echo <<< EOM
  <tr>
   

出典情報

Medium

PHP逆引き大全 516の極意

  • 著者: 大家 正登, 茂木 健一, 鮫島 康浩, 谷中 志織

コメント

    コメントはありません