Data Mapper pattern and duplicate objects

I'm using the data mapper pattern in a PHP app I'm developing and have a question. At present, you request a Site object with a specific ID and the mapper will lookup the row, create an object and return it. However, if you do this again for the same Site you end up with two different objects with identical data. eg.: $mapper = new Site_Mapper(); $a = $mapper->get(1); $b = $mapper-

数据映射器模式和重复对象

我正在开发一个PHP应用程序中使用数据映射器模式,并有一个问题。 目前,您请求具有特定ID的Site对象,映射器将查找该行,创建一个对象并将其返回。 但是,如果您再次为同一个网站执行此操作,则最终会生成两个具有相同数据的不同对象。 例如。: $mapper = new Site_Mapper(); $a = $mapper->get(1); $b = $mapper->get(1); $a == $b // true $a === $b // false 所以,我的问题是,我应该: 将实例化的Site对象

Keeping DAO and domain object separate

I've got a User domain object class, and a UserDAO class. The User only cares about it's state, and UserDAO only about the data storage. From what I've read, they should not know nor care about each other. I then wondered how I could use my User class to do things with UserDAO and vice versa. After some research I found out about Service classes, that they're supposed to coup

保持DAO和域对象分离

我有一个用户域对象类和一个UserDAO类。 用户只关心它的状态,而UserDAO只关心数据存储。 从我读过的内容来看,他们不应该彼此都知道也不在乎。 然后我想知道如何使用User类来处理UserDAO,反之亦然。 经过一些研究后,我发现了Service类,他们应该将一堆相关的类耦合在一起,以便在我的情况下交互User和UserDAO)。 如果DAO不应该知道也不关心域对象,为什么我会看到一些DAO接受它们相应的域对象作为参数,甚至返回它?

PHP how to implement the Data Mapper pattern in MVC

I'm trying to implement and get my grasp on the Data Mapper pattern in my MVC project. I know this has been asked before, but I'm still not sure if I'm moving in the right direction. I've pasted my Controller, Datamapper and Domain Object/Entity code right below: Controller The user lands on mywebsite.com/dashboard/index and gets to see a list of events from the event log da

PHP如何在MVC中实现Data Mapper模式

我试图在我的MVC项目中实现并掌握Data Mapper模式。 我知道这已经被问过,但我仍然不确定我是否正朝着正确的方向前进。 我在下面粘贴了我的Controller,Datamapper和Domain Object / Entity代码: 调节器 用户登陆mywebsite.com/dashboard/index并从事件日志数据库表中查看事件列表。 index()函数创建一个Datamapper实例并传递数据库包装器。 然后,使用从数据映射器获取的数据动态生成HTML表格。 class DashboardCont

Zend Data Mapper design

I'm using Zend Framework and following the design pattern of separating the Data layer from the Domain layer the problem raises when implementing the methods for the Data mapper so i implemented the save() which insert & update based on whether domain model contains id property and find() which return the records domain object based on id parameter but what if i need to search all/some

Zend数据映射器设计

我正在使用Zend Framework,并遵循将数据层从域层分离出来的设计模式,在实现Data映射器的方法时引发问题,所以我实现了save() ,它根据域模型是否包含id属性来插入和更新和find()哪些返回记录域对象基于id参数,但如果我需要 搜索表中的所有/某些行并返回所有列 搜索相同的行并返回一个mysql COUNT值 我应该直接使用继承了Zend_Db_Table_Abstract的类来满足这些需求,还是应该为每个需求实现方法? 我对如何划分符合我

Zend Framework Model Design

I am building an application in Zend Framework. My model is made up of three layers, domain classes, data mapper classes and a service layer which provides an interface for all external communication. Currently the data mapper classes are only used within my service layer and the domain classes are simple php objects only containing information specific to their domain. A very rough example of

Zend框架模型设计

我正在Zend Framework中构建一个应用程序。 我的模型由三个层组成,域类,数据映射器类和为所有外部通信提供接口的服务层。 目前,数据映射器类仅用于我的服务层,而域类是仅包含特定于其域的信息的简单php对象。 我的意思是一个非常粗略的例子.... //domain class public class User{ // data and functions specific to the user domain } //service class public class UserService{ // service contains an insta

Is this the common structure for the domain mapper model?

Hopefully i am asking this on the right stack exchange forum. If not please do let me know and I will ask somewhere else. I have also asked on Code Review, but the community seems a lot less active. As I have self learned PHP and all programming in general, I have only recently found out about 'Data Mappers' which allows data to be passed into classes without said classes knowing wher

这是域映射模型的常见结构吗?

希望我在正确的堆栈交换论坛上提出这个问题。 如果不是,请让我知道,我会问别的地方。 我也问过Code Review,但社区看起来不太活跃。 由于我自学了PHP和所有编程,我最近才发现了'数据映射器',它允许数据传入类中,而不需要所述类知道数据来自哪里。 我已经阅读了一些使用映射器的积极因素,以及为什么他们更容易在后来执行升级,但是我非常努力地找出在目录结构中使用映射器及其布局的建议方式。 假设我们有一

PHP MVC: Data Mapper pattern: class design

I have a web MVC application with domain objects and data mappers. The class methods of the data mappers contain all database querying logic. I'm trying to avoid mirroring any database structure and, therefore, to achieve the maximum flexibility in constructing the sql statements. So, in principle, I'm trying to not make use of any ORM or ActiveRecord structure/pattern AT ALL. Let me

PHP MVC:数据映射器模式:类设计

我有一个带有域对象和数据映射器的Web MVC应用程序。 数据映射器的类方法包含所有数据库查询逻辑。 我试图避免镜像任何数据库结构,因此,在构建sql语句时实现最大的灵活性。 所以,原则上,我试图不使用任何ORM或ActiveRecord结构/模式AT ALL。 让我给你一个例子:通常,我可以有一个抽象类AbstractDataMapper继承所有特定的数据映射类 - 就像UserDataMapper类。 然后,我可以定义一个findById()的方法AbstractDataMapper

'ticked' checkbox in php wordpress

This question already has an answer here: What's the proper value for a checked attribute of an HTML checkbox? 7 answers 您可以使用checked属性: echo '<input type="checkbox" class="chkLink alignleft" checked>';

'在'wordpress'勾选'复选框

这个问题在这里已经有了答案: HTML复选框的checked属性的值是多少? 7个答案 您可以使用checked属性: echo '<input type="checkbox" class="chkLink alignleft" checked>';

JQuery ignoring click() and change()

Advance note: I have already looked at and looked at and tried the solutions in the SO question: Jquery checkbox change and click event. Others on SO deal more with reading the values rather than the issue that the event is not firing. I will admit that I am a relative newbie to JQuery. I am trying to make two changes. One when a text field changes and one when a checkbox is toggled. Both

JQuery忽略click()和change()

提前说明:我已经看过,看过并尝试过SO问题中的解决方案:Jquery复选框更改和单击事件。 SO上的其他人更多的是阅读价值观,而不是事件没有解决的问题。 我承认我是JQuery的新手。 我正在尝试做两个更改。 一个是文本字段发生变化,另一个是复选框被切换。 两者都在一个表格内。 这个想法是,如果文本字段改变了计算,并且复选框后的返回值被写入文本。 该复选框打开和关闭该文本。 一旦完成表格可以提交。 代码(如

How to fetch a Book Title from an ISBN number?

I am planning on creating a small website for my personal book collection. To automate the process a little bit, I would like to create the following functionality: The website will ask me for the ISBN number of the book and will then automatically fetch the title and add it to my database. Although I am mainly interested in doing this in php, I also have some Java implementation ideas for t

如何从ISBN号获取书名?

我正计划为我的个人藏书创建一个小型网站。 为了使该过程自动化一点,我想创建以下功能: 网站会询问我书本的ISBN号码,然后自动获取标题并将其添加到我的数据库中。 虽然我主要对在php中这样做感兴趣,但我也有一些Java实现的想法。 如果答案尽可能地与语言无关,我相信它也可能有所帮助。 这是LibraryThing的创始人。 我们在这里没有什么可以提供的,所以我希望我的意见不会自私。 首先,关于亚马逊,ASIN和ISBN编