zoukankan      html  css  js  c++  java
  • SpeedPHP关于一对一和一对多关联关系的建立 model建立

    新闻表:t_news

    新闻类型表:b_type_to_name

    其中一个新闻类型可以包含多个新闻(hasmany),一个新闻只能属于一种新闻类型(hasone)

    下面是新闻model类:

    <?php
    
    /**
     * 新闻
     * @author HYY
     *
     */
    class m_news extends spModel {
        var $pk = "id"; // 每个留言唯一的标志,可以称为主键
        var $table = "t_news"; // 数据表的名称
        
        var $linker = array(
                array(
                        'type' => 'hasone',   // 一对多关联
                        'map' => 'typeToName',    // 关联的标识
                        'mapkey' => 'type_id',// 本表与对应表关联的字段名(意义:拿本表的哪个字段与另外一个表关联)
                        'fclass' => 'm_typeToName',// 对应表的类名
                        'fkey' => 'typeId', // 对应表中关联的字段名(意义:另外一个表的字段)
                        'enabled' => true // 启用关联
                )
        );
    }
    
    ?>

    这个是新闻类型类:

    <?php
    
    /**
     * 新闻类型
     * @author HYY
     *
     */
    class m_typeToName extends spModel{
        var $pk = "typeId"; // 每个留言唯一的标志,可以称为主键
        var $table = "b_type_to_name"; // 数据表的名称
        
        var $linker = array(
                array(
                        'type' => 'hasmany',   // 一对多关联
                        'map' => 'newsSet',    // 关联的标识
                        'mapkey' => 'typeId',// 本表与对应表关联的字段名
                        'fclass' => 'm_news',// 对应表的类名
                        'fkey' => 'type_id', // 对应表中关联的字段名
                        'enabled' => true // 启用关联
                )
        );
    }
    
    ?>
  • 相关阅读:
    需求采集
    <转>jmeter(十七)目录结构
    《Google软件测试之道》测试开发工程师
    聊聊学习和读书这件事
    聊聊用户
    jmeter(十六)配置元件之计数器
    《探索性软件测试》
    一个完整的性能测试流程
    js外部样式和style属性的添加移除
    jquery获取第一层li
  • 原文地址:https://www.cnblogs.com/wuyou/p/3495345.html
Copyright © 2011-2022 走看看