日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > php框架 > ZendFramework > Zend Framework教程-Zend_Db-數(shù)據(jù)庫(kù)操作6-Zend_Db_Table_Definition翻譯

Zend Framework教程-Zend_Db-數(shù)據(jù)庫(kù)操作6-Zend_Db_Table_Definition翻譯

來(lái)源:程序員人生   發(fā)布時(shí)間:2013-11-14 02:02:44 閱讀次數(shù):4437次

Introduction 簡(jiǎn)介

Zend_Db_Table_Definition is a class that can be used to describe the relationships and configuration options that should be used when Zend_Db_Table is used via concrete instantiation.

Zend_Db_Table_Definition  用于定義關(guān)聯(lián)關(guān)系和對(duì)實(shí)例化Zend_Db_Table的相關(guān)選項(xiàng)配置的類。

Basic Usage

For all of the same options that are available when configuring an extendedZend_Db_Table_Abstract class, those options are also available when describing a definition file. 

 所有繼承實(shí)現(xiàn)Zend_Db_Table_Abstract 類的配置選項(xiàng),都是可以使用定義描述文件的。

This definition file should be passed to the class at instantiation time so that it can know the full definition of all tables in said definition.

通過(guò)在實(shí)例化時(shí),將表的定義文件傳遞給類。


Below is a definition that will describe the table names and relationships between table objects. 


下面是表名和表對(duì)象之間的關(guān)聯(lián)關(guān)系的定義。


Note: if 'name' is left out of the definition, it will be taken as the key of the defined table (an example of this is in the 'genre' section in the example below.)

注:如果“name”的定義被省略了,將采用表定義的key值(例如下面的“genre”部分)。

Example #1 Describing the Definition of a Database Data Model  數(shù)據(jù)庫(kù)的數(shù)據(jù)模型定義描述


$definition = new Zend_Db_Table_Definition(array(    'author' => array(        'name' => 'author',        'dependentTables' => array('book')        ),    'book' => array(        'name' => 'book',        'referenceMap' => array(            'author' => array(                'columns' => 'author_id',                'refTableClass' => 'author',                'refColumns' => 'id'                )            )        ),    'genre' => null,    'book_to_genre' => array(        'referenceMap' => array(            'book' => array(                'columns' => 'book_id',                'refTableClass' => 'book',                'refColumns' => 'id'                ),            'genre' => array(                'columns' => 'genre_id',                'refTableClass' => 'genre',                'refColumns' => 'id'                )            )        )    ));



As you can see, the same options you'd generally see inside of an extended Zend_Db_Table_Abstract class are documented in this array as well. 


正如你看到的,繼承實(shí)現(xiàn)Zend_Db_Table_Abstract類時(shí)相同的選項(xiàng),也要在這個(gè)數(shù)組中定義。


When passed into  Zend_Db_Table constructor, this definition ispersisted to any tables it will need to create in order to return the proper rows.

當(dāng)傳入  Zend_Db_Table 構(gòu)造函數(shù)時(shí), 這個(gè)定義會(huì)被持久化到所有表中。它必須被創(chuàng)建目的是為了返回對(duì)應(yīng)的行 。

Below is an example of the primary table instantiation as well as thefindDependentRowset() and findManyToManyRowset() calls that will correspond to the data model described above:

下面是通過(guò)上面定義的主表實(shí)例化的例子,然后調(diào)用 findDependentRowset()和 findManyToManyRowset()方法:


Example #2 Interacting with the described definition 描述定義使用

   

$authorTable = new Zend_Db_Table('author', $definition);$authors = $authorTable->fetchAll(); foreach ($authors as $author) {    echo $author->id       . ': '       . $author->first_name       . ' '       . $author->last_name       . PHP_EOL;    $books = $author->findDependentRowset('book');    foreach ($books as $book) {        echo '    Book: ' . $book->title . PHP_EOL;        $genreOutputArray = array();        $genres = $book->findManyToManyRowset('genre', 'book_to_genre');        foreach ($genres as $genreRow) {            $genreOutputArray[] = $genreRow->name;        }        echo '        Genre: ' . implode(', ', $genreOutputArray) . PHP_EOL;    }}


Advanced Usage高級(jí)用法


Sometimes you want to use both paradigms for defining and using the table gateway: both by extension and concrete instantiation.To do this simply leave out any table configurations out of the definition. 

有時(shí)可能會(huì)同時(shí)使用Zend_Db_Table和 Zend_Db_Table_Definition。要做到這一點(diǎn),只需實(shí)現(xiàn)所有表的定義,即可。

This will allow Zend_Db_Table to look for the actual refered class instead of the definition key.

允許采用Zend_Db_Table的具體類代替定義的KEY

Building on the example above, we will allow for one of the table configurations to be aZend_Db_Table_Abstract extended class, while keeping the rest of the tables as part of the definition. 

基于上面的例子, 我們可以配置其中一個(gè) 實(shí)例化Zend_Db_Table_Abstract 的類,   而其它的表保持原有定義。

We will also show how one would interact with this new definition.

以下是具體的定義。


Example #3 Interacting A Mixed Use Zend_Db_Table Definition 混合使用Zend_Db_Table定義


class MyBook extends Zend_Db_Table_Abstract{    protected $_name = 'book';    protected $_referenceMap = array(        'author' => array(            'columns' => 'author_id',            'refTableClass' => 'author',            'refColumns' => 'id'            )        );} $definition = new Zend_Db_Table_Definition(array(    'author' => array(        'name' => 'author',        'dependentTables' => array('MyBook')        ),    'genre' => null,    'book_to_genre' => array(        'referenceMap' => array(            'book' => array(                'columns' => 'book_id',                'refTableClass' => 'MyBook',                'refColumns' => 'id'                ),            'genre' => array(                'columns' => 'genre_id',                'refTableClass' => 'genre',                'refColumns' => 'id'                )            )        )    )); $authorTable = new Zend_Db_Table('author', $definition);$authors = $authorTable->fetchAll(); foreach ($authors as $author) {    echo $author->id       . ': '       . $author->first_name       . ' '       . $author->last_name       . PHP_EOL;    $books = $author->findDependentRowset(new MyBook());    foreach ($books as $book) {        echo '    Book: ' . $book->title . PHP_EOL;        $genreOutputArray = array();        $genres = $book->findManyToManyRowset('genre', 'book_to_genre');        foreach ($genres as $genreRow) {            $genreOutputArray[] = $genreRow->name;        }        echo '        Genre: ' . implode(', ', $genreOutputArray) . PHP_EOL;    }}





-----------

對(duì)譯文與原文在含義上的差異而造成的誤解不承擔(dān)任何責(zé)任。僅供參考。 




生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 成人在线精品 | 黄色毛片网站 | www.亚洲色图.com| 欧美成人看片黄a免费看 | 在线播放毛片 | 成人精品视频在线 | 一级欧美 | 在线视频精品一区 | 蜜桃视频一区二区三区 | 一区二区三区国产片 | 日韩视频在线免费观看 | 久久精品国产一区 | 黄色免费网 | 久久久久av | www.射 | 久久免费国产精品1 | 日产一二三四五六区传媒 | 最新中文字幕在线视频 | 国产一区二区在线免费观看 | 欧美日韩视频免费观看 | 动漫一区二区 | av在线成人 | 国产二区免费 | 亚洲精品一区二区三区99 | 91久久国产综合久久蜜月精品 | 免费黄色在线看 | 精品久久一区二区三区 | 青草青青在线视频 | 一本色道久久88综合亚洲精品ⅰ | 欧美日韩精品一区 | 人人cao| 国产免费一区二区 | 国产一区福利 | 麻豆网站 | 成人精品一区二区三区校园激情 | 国产高清精品一区二区三区 | 成人黄色大片免费看 | 久久国产精品99久久久久久牛牛 | 欧美天堂在线观看 | 欧美一区二区三区免费观看 | 国产精品免费一区二区 |