activerecord

代码整洁之道(中文完整版)pdf

旧巷老猫 提交于 2020-05-01 14:37:18
下载地址: 网盘下载 内容简介 · · · · · · 《代码整洁之道(英文版)》提出一种观念:代码质量与其整洁度成正比。干净的代码,既在质量上较为可靠,也为后期维护、升级奠定了良好基础。作为编程领域的佼佼者,《代码整洁之道(英文版)》作者给出了一系列行之有效的整洁代码操作实践。这些实践在《代码整洁之道(英文版)》中体现为一条条规则(或称“启示”),并辅以来自现实项目的正、反两面的范例。只要遵循这些规则,就能编写出干净的代码,从而有效提升代码质量。 软件质量,不但依赖于架构及项目管理,而且与代码质量紧密相关。这一点,无论是敏捷开发流派还是传统开发流派,都不得不承认。 《代码整洁之道(英文版)》阅读对象为一切有志于改善代码质量的程序员及技术经理。书中介绍的规则均来自作者多年的实践经验,涵盖从命名到重构的多个编程方面,虽为一“家”之言,然诚有可资借鉴的价值。 作者简介 · · · · · · Rober C.Martin,Object Mentor公司总裁。面向对象设计、模式、UML、敏捷方法学和极限编程领域的资深顾问。他是Designing Object-Oriented C++Applications Using the BoochMethod以及Jolt获奖图书Agile SoftwareDevelopment,Principles,Pattems,and Practices

2018开源中国最受欢迎的中国软件MyBatis-Plus

给你一囗甜甜゛ 提交于 2020-04-19 05:41:53
2018开源中国最受欢迎的中国软件MyBatis-Plus 官方网址: https://mp.baomidou.com 中国软件,中文文档 什么是MyBatis-Plus? 进入官方第一句话:为简化开发而生 ; 只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑。 只需简单配置,即可快速进行 CRUD 操作,从而节省大量时间。 丰富功能:热加载、代码生成、分页、性能分析等功能一应俱全。 我愿景是成为 MyBatis 最好的搭档,就像 魂斗罗 中的 1P、2P,基友搭配,效率翻倍。 特性 无侵入 :只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑 损耗小 :启动即会自动注入基本 CURD,性能基本无损耗,直接面向对象操作 强大的 CRUD 操作 :内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求 支持 Lambda 形式调用 :通过 Lambda 表达式,方便的编写各类查询条件,无需再担心字段写错 支持多种数据库 :支持 MySQL、MariaDB、Oracle、DB2、H2、HSQL、SQLite、Postgre、SQLServer2005、SQLServer 等多种数据库 支持主键自动生成 :支持多达 4 种主键策略(内含分布式唯一 ID 生成器 - Sequence)

How to disconnect from a particular database in rails?

和自甴很熟 提交于 2020-04-10 08:10:49
问题 I use this snippet to connect to another db ActiveRecord::Base.establish_connection.... but I don't know how to delete this connection after it is not needed. 回答1: You can call remove_connection old_connection = ActiveRecord::Base.remove_connection If you have done something like the following (where there is an assignment) new_connection = ActiveRecord::Base.establish_connection(...) This can be passed on to remove_connection old_connection = ActiveRecord::Base.remove_connection(new

Rails change column type and update column values

两盒软妹~` 提交于 2020-03-18 12:18:47
问题 I have a table called Users with a column Active that is type boolean. I will soon need to change the type of that column to string. I will also need to change all of the column values of Active from :true to "active" and :false to "inactive". To change the column type I would use Change a column type from Date to DateTime during ROR migration class ChangeColumnTypeInUsers < ActiveRecord::Migration def up change_column :users, :active, :string end def down change_column :users, :active,

after_initialize & after_find callbacks order in Active Record object life cycle?

蹲街弑〆低调 提交于 2020-03-17 05:20:27
问题 From the Rails Guides. Callbacks could hook into Active Record Object's life cycle. In the order of execution, they're (copied from Rails Guides): Creating an Object before_validation after_validation before_save around_save before_create around_create after_create after_save after_commit/after_rollback Updating an Object before_validation after_validation before_save around_save before_update around_update after_update after_save after_commit/after_rollback Destroying an Object before

codeigniter ActiveRecord where statement issue

好久不见. 提交于 2020-03-06 09:15:37
问题 is have this statement and i want to make it by the Active Records way in codeigniter DELETE FROM TABLE (col1 = value AND col2 = value2 ) OR (col1 = value2 AND col2 = value ); 回答1: CodeIgniter Active Record is impractical for mixing AND's and OR's within a query. You will likely need to construct some of the query manually, e.g. something along the lines of: $this->db->where("col1 = $value AND col2 = $value2"); $this->db->or_where("col1 = $value2 AND col2 = $value"); Alternately, in your

left join with ActiveRecord (yii2)

二次信任 提交于 2020-03-06 02:37:08
问题 I tried to send SQL request with LEFT JOIN but it doesn't display data from table2 table. public static function top($limit) { return self::findBySql(" SELECT * FROM table 1 g1 LEFT JOIN table2 s1 ON (g1.id = s1.g_id AND s1.id = ( SELECT MAX(id) FROM table2 s2 WHERE s2.g_id = g1.id )) LIMIT :limit", [':limit' => $limit] )->all(); } 回答1: It seems you are adding this function to the model and self represents the model itself. Yii will not return results from another table and will be limited to

rake db:migrate not working when using ActiveRecord with Sinatra

倖福魔咒の 提交于 2020-03-04 21:40:09
问题 I am trying to create a very basic Sinatra app which uses only Active Record and Sqlite3. To be as complete as possible I am following instructions from a tutorial which states the following steps in order: Create a database by putting the following code in the main app file: ActiveRecord::Base.establish_connection( :adapter =>'sqlite3', :database=>'wiki.db' ) class User < ActiveRecord::Base validates :username, presence: true, uniqueness: true validates :password, presence: true end To

基于 Java 的 Active Record 开源项目

狂风中的少年 提交于 2020-03-01 05:41:33
Active Record 是什么?也许很多做 Java 的朋友并没有听说过这个概念,但它确实很早就已经出现了。 确切地说,应该是在 2003 年,由世界大师级人物 Martin Fowler(马丁 · 福勒)在他写的一本叫做《企业应用架构模式》书里就描述过这个模式。不可否认,马丁是软件架构的泰斗,他写的每本书,我都买过,虽然很多内容我还看不懂,但每次阅读都有新的认识,虽然这些文字已经很陈旧了。 如果您想了解关于 Active Record 的权威定义,可以点击下面的维基百科地址: http://zh.wikipedia.org/wiki/Active_Record 当然,如果您想听到更通俗易懂的言语,我可以试着描述一下: 它是面向领域对象的设计模式 它为每个领域对象提供一组 CRUD 方法 以上提到的 领域对象 实际上就是我们经常说的 Entity (实体)。 Active Record 模式最早是在 Ruby on Rails(RoR)里取得了最佳实践,然后其它开发语言开始效仿,比如:PHP、Python 等,当然 Java 也不例外。 这几天我收集了几款基于 Java 的 Active Record 开源项目,这些项目都非常优秀,让我收获良多、受益匪浅!所以我忍不住想与大家分享一下我的学习心得与体会。 需要申明的是:本文仅代表个人看法,本人仅站在使用者的角度来体验这些产品