Zend_Db_Table 기본 키를 기준으로 데이터 공식 설명서 오류 찾기

공식 안내서에는 다음과 같은 내용이 나와 있습니다.
 

주 키로 데이터 찾기


find () 방법을 호출하면 메인 키 값을 사용하여 테이블에서 데이터를 쉽게 검색할 수 있습니다.만약 당신이 어떤 데이터만 조회하고 싶다면, 이 방법은zend 로 되돌아옵니다db_table_row 대상, 여러 개의 기록을 조회하려면zenddb_table_rowset 대상입니다.

<?php
class RoundTable extends Zend_Db_Table {}

$table = new RoundTable();

// SELECT * FROM round_table WHERE id = "1"
$row = $table->find(1);

// SELECT * FROM round_table WHERE id IN("1", "2", 3")
$rowset = $table->find(array(1, 2, 3));
?>
         

"만약 한 데이터만 조회하고 싶다면, 이 방법은zend db table row 대상 오류로 되돌아갈 것입니다. 테스트를 통해 되돌아오는 것도"zend db table rowset 대상 "입니다.
코드:
require_once 'Zend/Db.php';
$params = array(
    'host' => '127.0.0.1',
    'username' => 'root',
    'password' => '',
    'dbname' => 'guestbook'
);
$db = Zend_Db::factory('PDO_MYSQL', $params);
//모든 ZendDb_Table 객체 기본 adapter 설정
require_once 'Zend/Db/Table.php';
Zend_Db_Table::setDefaultAdapter($db);
class Guestbook extends Zend_Db_Table {    
}
$table = new Guestbook();
//SELECT * FROM round_table WHERE id = "1"
$row = $table->find(1);
var_dump($row);
//SELECT * FROM round_table WHERE id IN("1", "2", 3")
$rowset = $table->find(array(1, 2, 3));
var_dump($rowset);
?>
결과:
object(Zend_Db_Table_Rowset)[6]
  protected '_data' => 
    array
      0 => 
        array
          'id' => string '1' (length=1)
          'email' => string '[email protected]' (length=24)
          'comment' => string 'Hello! Hope you enjoy this sample zf application!' (length=49)
          'created' => string '2011-10-14 09:09:56' (length=19)
  protected '_table' => 
    object(Guestbook)[3]
      protected '_definition' => null
      protected '_definitionConfigName' => null
      protected '_db' => 
        object(Zend_Db_Adapter_Pdo_Mysql)[1]
          protected '_pdoType' => string 'mysql' (length=5)
          protected '_numericDataTypes' => 
            array
              ...
          protected '_defaultStmtClass' => string 'Zend_Db_Statement_Pdo' (length=21)
          protected '_config' => 
            array
              ...
          protected '_fetchMode' => int 2
          protected '_profiler' => 
            object(Zend_Db_Profiler)[2]
              ...
          protected '_defaultProfilerClass' => string 'Zend_Db_Profiler' (length=16)
          protected '_connection' => 
            object(PDO)[4]
              ...
          protected '_caseFolding' => int 0
          protected '_autoQuoteIdentifiers' => boolean true
          protected '_allowSerialization' => boolean true
          protected '_autoReconnectOnUnserialize' => boolean false
      protected '_schema' => null
      protected '_name' => string 'Guestbook' (length=9)
      protected '_cols' => 
        array
          0 => string 'id' (length=2)
          1 => string 'email' (length=5)
          2 => string 'comment' (length=7)
          3 => string 'created' (length=7)
      protected '_primary' => 
        array
          1 => string 'id' (length=2)
      protected '_identity' => int 1
      protected '_sequence' => boolean true
      protected '_metadata' => 
        array
          'id' => 
            array
              ...
          'email' => 
            array
              ...
          'comment' => 
            array
              ...
          'created' => 
            array
              ...
      protected '_metadataCache' => null
      protected '_metadataCacheInClass' => boolean true
      protected '_rowClass' => string 'Zend_Db_Table_Row' (length=17)
      protected '_rowsetClass' => string 'Zend_Db_Table_Rowset' (length=20)
      protected '_referenceMap' => 
        array
          empty
      protected '_dependentTables' => 
        array
          empty
      protected '_defaultSource' => string 'defaultNone' (length=11)
      protected '_defaultValues' => 
        array
          empty
  protected '_connected' => boolean true
  protected '_tableClass' => string 'Guestbook' (length=9)
  protected '_rowClass' => string 'Zend_Db_Table_Row' (length=17)
  protected '_pointer' => int 0
  protected '_count' => int 1
  protected '_rows' => 
    array
      empty
  protected '_stored' => boolean true
  protected '_readOnly' => boolean false
object(Zend_Db_Table_Rowset)[7]
  protected '_data' => 
    array
      0 => 
        array
          'id' => string '1' (length=1)
          'email' => string '[email protected]' (length=24)
          'comment' => string 'Hello! Hope you enjoy this sample zf application!' (length=49)
          'created' => string '2011-10-14 09:09:56' (length=19)
      1 => 
        array
          'id' => string '2' (length=1)
          'email' => string '[email protected]' (length=11)
          'comment' => string 'Baz baz baz, baz baz Baz baz baz - baz baz baz.' (length=47)
          'created' => string '2011-10-14 09:09:56' (length=19)
  protected '_table' => 
    object(Guestbook)[3]
      protected '_definition' => null
      protected '_definitionConfigName' => null
      protected '_db' => 
        object(Zend_Db_Adapter_Pdo_Mysql)[1]
          protected '_pdoType' => string 'mysql' (length=5)
          protected '_numericDataTypes' => 
            array
              ...
          protected '_defaultStmtClass' => string 'Zend_Db_Statement_Pdo' (length=21)
          protected '_config' => 
            array
              ...
          protected '_fetchMode' => int 2
          protected '_profiler' => 
            object(Zend_Db_Profiler)[2]
              ...
          protected '_defaultProfilerClass' => string 'Zend_Db_Profiler' (length=16)
          protected '_connection' => 
            object(PDO)[4]
              ...
          protected '_caseFolding' => int 0
          protected '_autoQuoteIdentifiers' => boolean true
          protected '_allowSerialization' => boolean true
          protected '_autoReconnectOnUnserialize' => boolean false
      protected '_schema' => null
      protected '_name' => string 'Guestbook' (length=9)
      protected '_cols' => 
        array
          0 => string 'id' (length=2)
          1 => string 'email' (length=5)
          2 => string 'comment' (length=7)
          3 => string 'created' (length=7)
      protected '_primary' => 
        array
          1 => string 'id' (length=2)
      protected '_identity' => int 1
      protected '_sequence' => boolean true
      protected '_metadata' => 
        array
          'id' => 
            array
              ...
          'email' => 
            array
              ...
          'comment' => 
            array
              ...
          'created' => 
            array
              ...
      protected '_metadataCache' => null
      protected '_metadataCacheInClass' => boolean true
      protected '_rowClass' => string 'Zend_Db_Table_Row' (length=17)
      protected '_rowsetClass' => string 'Zend_Db_Table_Rowset' (length=20)
      protected '_referenceMap' => 
        array
          empty
      protected '_dependentTables' => 
        array
          empty
      protected '_defaultSource' => string 'defaultNone' (length=11)
      protected '_defaultValues' => 
        array
          empty
  protected '_connected' => boolean true
  protected '_tableClass' => string 'Guestbook' (length=9)
  protected '_rowClass' => string 'Zend_Db_Table_Row' (length=17)
  protected '_pointer' => int 0
  protected '_count' => int 2
  protected '_rows' => 
    array
      empty
  protected '_stored' => boolean true
  protected '_readOnly' => boolean false

좋은 웹페이지 즐겨찾기