下载直接可用的基础 动态 AR 模型
内部结构为:
/** * @author caihaibin * @qq 243008827 * 这个类是最新完善的,动态类似处理, * 可重复使用而不会影响其它的调用。 * 是居家旅行必备之良品 */ class CActiveRecordX extends CActiveRecord{ private static $_models=array(); private $_i_tableName; private static $tableName; private static $_i_md=array(); private $_md; public function getMetaData() { if($this->_md!==null) return $this->_md; else return $this->_md=self::model(self::tableName(),get_class($this))->_md; } public static function model($table_name,$className=__CLASS__) { self::$tableName = $table_name; if(isset(self::$_models[$table_name])){ return self::$_models[$table_name]; }else { $model=self::$_models[$table_name]=new $className(null); $model->_md=new CActiveRecordMetaData($model); $model->attachBehaviors($model->behaviors()); return $model; } } public function __construct($table_name = '') { if ($table_name === null) { parent::__construct ( null ); } else { self::$tableName = $table_name; parent::__construct (); } } public function tableName() { if (! isset ( $this->_i_tableName )) { $this->_i_tableName = self::$tableName; } return $this->_i_tableName; } } class ArticleX extends CActiveRecordX{ public static function getClassName() { return __CLASS__; } }
该类在别人的基础上做的修改,
好吧,这个可以说是接近原创了,因为原著是个sb,哥不多说了。
这个是模拟了继承了ar修改了内部的主要涉及函数,实现通过表名进行标记。
不会有内部数据结构重复的情况,其它bug请反馈。
因为原来的 public function tableName() 内部为静态返回,如果有多个的情况下。
返回表名有问题。
现做了内部变量的包装,这样可以在最大的限度下保证 实例的完整性
转发请注明出处http://blog.martoo.cn
如有漏缺,请联系我 QQ 243008827
Simply desire to say your article is as astounding. The clearness in your post is just cool and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please carry on the enjoyable work.
Thank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how can we communicate?
Thank you for share very good knowledges. Your web is very goodI am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more. You, my friend, ROCK! I found just the information I already searched everywhere and just couldn’t find. What a perfect site. Like this website your website is one of my new favs.I like this data presented and it has given me some sort of commitment to succeed for some reason, so keep up the good work!
Unquestionably believe that which you stated. Your favorite justification appeared to be on the net the simplest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people can take a signal. Will likely be back to get more. Thanks
Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a bit, but other than that, this is excellent blog. A great read. I will certainly be back.
Pretty section of content. I just stumbled upon your site and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I’ll be subscribing to your feeds and even I achievement you access consistently rapidly.
I became just browsing occasionally in addition to you just read this post. I need to admit that we are within the hand of luck today if not owning such an excellent write-up to determine wouldn’t are achievable for me, at the incredibly least. Really enjoy your content.
Interesting write-up and a single which needs to be more extensively known about in my view. Your level of detail is very good and also the clarity of writing is excellent. I have bookmarked it for you personally so that others are going to be in a position to see what it is advisable to say.
Along with everything which appears to be developing throughout this subject matter, many of your points of view tend to be quite refreshing. However, I appologize, because I can not subscribe to your entire plan, all be it refreshing none the less. It looks to everyone that your commentary are generally not totally rationalized and in actuality you are generally your self not even entirely confident of the assertion. In any case I did take pleasure i examining it.
Thing you are talking about a lot of sense. Yet, consider this, let’s suppose you integrated a little more? I am talking about, I do not want to teach how to run your site, however if you added something which could grab people’s particular attention? Just as a video or simply a graphic or maybe few for getting people psyched concerning what you are talking about.
Its Pleasure to realize your blog.The over content is relatively extraordinary, and I really enjoyed reading your blog and points that you just expressed. I incredibly like to glimpse back over a regular basis,post additional from the topic.Thanks for sharing…keep writing!
It’s the best time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read even more things about it!
I think this is among the most significant information for me. And i am glad reading your article. But should remark on few general things, The site style is wonderful, the articles is really nice : D. Good job, cheers
WOW! Incredible and well deserved.
Very nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed surfing around your blog posts. In any case I will be subscribing to your feed and I hope you write again soon!
we came across a cool web page which you could get pleasure from. Take a appear for those who want
Appreciate this post. Let me try it out.
This paragraph gives clear idea in favor of the new visitors of blogging, that really how to do running a blog.
Hi there, I check your blogs regularly. Your story-telling style is awesome, keep doing what
you’re doing!
Program ape
These are in fact impressive ideas in concerning blogging.
You have touched some good points here. Any way keep up wrinting.