【问题标题】:How does this class know what table to query?这个类如何知道要查询什么表?
【发布时间】:2013-12-29 18:02:11
【问题描述】:

http://pomm.coolkeums.org/documentation/manual-1.2#findwhere

可以直接使用它,因为我们在一个 Map 类中 Pomm 知道要在查询中使用哪些表和字段。

它说因为我们在 Map 类中,所以 Pomm 知道要查询什么表。它怎么知道我要查询什么表?

【问题讨论】:

  • 您是否在上面的文档页面中阅读过它解释了什么是地图类,并给出了代码示例?

标签: php database postgresql pomm


【解决方案1】:

来自您提供的链接

"Map 类表示数据库中的一个结构并提供方法 用这种结构检索和保存数据。简而言之,一张桌子 或查看 => 一个地图类。”

这意味着它知道您要查询哪个表,因为您在与该表关联的地图类中调用 findWhere()。

您在此处提供的链接的 [Introspected tables] 部分是一个示例 Map 类:

*在下面的代码中,object_name 属性指定了与该地图类相关的表名。*

 abstract class StudentMap extends BaseObjectMap
 {
     public function initialize()
     {
         $this->object_class =  '\College\PublicSchema\Student';
         $this->object_name  =  'student';

         $this->addField('reference', 'char');
         $this->addField('first_name', 'varchar');
         $this->addField('last_name', 'varchar');
         $this->addField('birthdate', 'timestamp');
         $this->addField('level', 'smallint');
         $this->addField('exam_dates', 'timestamp[]');

         $this->pk_fields = array('reference');
     }
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-20
    • 2020-12-04
    • 2013-03-14
    • 2011-08-27
    • 1970-01-01
    • 1970-01-01
    • 2015-07-03
    相关资源
    最近更新 更多