- 浏览: 111861 次
- 性别:
- 来自: 成都
文章分类
- 全部博客 (134)
- java (134)
- [转]sqlserver 数据类型 及使用考虑 (1)
- 保存、读取、删除到sdcard图片 (1)
- hashcode 重写 (1)
- sql2008导出数据 (1)
- Android开发(1):随机绘制彩色实心圆 (1)
- JPA 应用技巧 1:实体类和实体 DAO 模板 (1)
- 狩魂之神即将开测 - 2012年最值得期待的网页游戏 (1)
- mantis (1)
- MediaWiki (1)
- ExtMail (1)
- MDaemon搭建公司项目环境 (1)
- NIO 之 选择就绪模式 (1)
- web应用系统架构设计 (1)
- XML CDATA (1)
- firefox+Firebug调试JavaScript、HTML和CSS (1)
- 在SUSE 11中安装Windows虚拟机 (1)
- 将字节流(byte[])转换成文件 (1)
- HTML5网站 (1)
- 在Android中自定义IOS风格的按钮 (1)
- 基于SVG的WebGIS的一个雏形 (1)
- 程序名称DreamIT(梦想IT)提供许多IT公司的面试和笔试试题 (1)
- 介绍一个ASP.NET开发工具Web Matrix (1)
- C#信息采集工具实现 (1)
- Qt 4.7.4 完美动态编译发布动态调试,以及静态编译发布 (1)
- 2011面试题目之猴子偷桃 (1)
- Linux tar压缩时排除某个目录或文件的参数 (1)
- Crack JRebel 4.0,无需重启JVM,热部署解决方案 (1)
- Groovy Sql使用Spring的事务管理 (1)
- <<让oracle跑的更快1>>读书笔记2 (1)
- 不要再浪费时间 (1)
- JSP (1)
- PHP (1)
- Python (1)
- Ruby (1)
- Perl概要及各自特点 (1)
- JVM 内存结构(转) (1)
- [转载]JPA 批注参考(1) (1)
- Hadoop配置部分内容 (1)
- HD2刷机的基础知识 HD2的radio、HSPL、ROM三种组合 (1)
最新评论
-
alexyao8:
顶起
[G4Studio开源平台]如何搭建G4开发环境 -
greatghoul:
太二了。
不要再浪费时间 -
wengbo316:
它们一定是花果山的猴子,数数能数到3K多呢。。。
2011面试题目之猴子偷桃 -
mycar:
额.待补充...........
保存、读取、删除到sdcard图片 -
沙舟狼客:
这太折磨人了, 还有人要看吗?
[] javaeye rss抓取
ror里的查找主要使用find命令:
先贴一段api
find(*args)
<div class="description">find operates with four different retrieval approaches:
<h4>parameters</h4>
<h4>examples</h4><pre> # find first person.find(:first) # returns the first object fetched by select * from people person.find(:first, :conditions => [ "user_name = ?", user_name]) person.find(:first, :conditions => [ "user_name = :u", { :u => user_name }]) person.find(:first,rder => "created_on desc",ffset => 5) # find last person.find(:last) # returns the last object fetched by select * from people person.find(:last, :conditions => [ "user_name = ?", user_name]) person.find(:last,rder => "created_on desc",ffset => 5) # find all person.find(:all) # returns an array of objects for all the rows fetched by select * from people person.find(:all, :conditions => [ "category in (?)", categories], :limit => 50) person.find(:all, :conditions => { :friends => ["bob", "steve", "fred"] } person.find(:all,ffset => 10, :limit => 10) person.find(:all, :include => [ :account, :friends ]) person.find(:all, :group => "category")</pre>example for find with a lock: imagine twoconcurrent transactions: each will read <tt>person.visits == 2</tt>, add 1to it, and save, resulting in two saves of<tt>person.visits = 3</tt>. by locking the row, the second transaction hasto wait until the first is finished; we getthe expected <tt>person.visits == 4</tt>.
<pre> person.transaction do person = person.find(1, :lock => true) person.visits += 1 person.save! end</pre>
先贴一段api
find(*args)
<div class="description">find operates with four different retrieval approaches:
- find by id - this can either be a specificid (1), a list of ids (1, 5, 6), or anarray of ids ([5, 6, 10]). if no record can be found for all of the listed ids, then recordnotfound will be raised.
- find first - this will return the first record matched by the options used.these options can either be specific conditions or merely an order. if norecord can be matched, <tt>nil</tt> is returned. use <tt>model.find(:first, *args)</tt> or its shortcut<tt>model.first(*args)</tt>.
- find last - this will return the last record matched by the options used. theseoptions can either be specific conditions or merely an order. if no recordcan be matched, <tt>nil</tt> is returned. use <tt>model.find(:last, *args)</tt> or its shortcut<tt>model.last(*args)</tt>.
- find all - this will return all the records matched by the options used.if no records are found, an empty array is returned. use <tt>model.find(:all, *args)</tt> or its shortcut<tt>model.all(*args)</tt>.
<h4>parameters</h4>
- <tt>:conditions</tt> - an sql fragment like "administrator = 1",<tt>[ "user_name = ?", username ]</tt>, or <tt>["user_name =:user_name", { :user_name => user_name }]</tt>. see conditions inthe intro.
- <tt>:order</tt> - an sql fragment like "created_at desc, name".
- <tt>:group</tt> - an attribute name by which the result should be grouped.uses the <tt>group by</tt> sql-clause.
- <tt>:having</tt> - combined with +:group+ this can be used to filter therecords that a <tt>group by</tt> returns. uses the <tt>having</tt>sql-clause.
- <tt>:limit</tt> - an integer determining the limit on the number of rowsthat should be returned.
- <tt>:offset</tt> - an integer determining the offset from where the rowsshould be fetched. so at 5, it would skip rows 0 through 4.
- <tt>:joins</tt> - either an sql fragment for additional joins like"left join comments on comments.post_id = id" (rarely needed), named associationsin the same form used for the <tt>:include</tt> option, which will performan <tt>inner join</tt> on the associated table(s), or an array containing amixture of both strings and named associations. if the value is a string,then the records will be returned read-only since they will have attributes that do not correspond to thetable‘s columns. pass <tt>:readonly=> false</tt> to override.
- <tt>:include</tt> - names associations that should be loaded alongside. thesymbols named refer to already defined associations. see eager loadingunder associations.
- <tt>:select</tt> - by default, this is "*" as in "select *from", but can be changed if you, for example, want to do a join butnot include the joined columns. takes astring with the select sql fragment (e.g. "id, name").
- <tt>:from</tt> - by default, this is the table name of the class, but canbe changed to an alternate table name (or even the name of a databaseview).
- <tt>:readonly</tt> - mark the returned records read-only so they cannot besaved or updated.
- <tt>:lock</tt> - an sql fragment like "for update" or "lockin share mode". <tt>:lock => true</tt> gives connection‘s default exclusive lock,usually "for update".
<h4>examples</h4><pre> # find first person.find(:first) # returns the first object fetched by select * from people person.find(:first, :conditions => [ "user_name = ?", user_name]) person.find(:first, :conditions => [ "user_name = :u", { :u => user_name }]) person.find(:first,rder => "created_on desc",ffset => 5) # find last person.find(:last) # returns the last object fetched by select * from people person.find(:last, :conditions => [ "user_name = ?", user_name]) person.find(:last,rder => "created_on desc",ffset => 5) # find all person.find(:all) # returns an array of objects for all the rows fetched by select * from people person.find(:all, :conditions => [ "category in (?)", categories], :limit => 50) person.find(:all, :conditions => { :friends => ["bob", "steve", "fred"] } person.find(:all,ffset => 10, :limit => 10) person.find(:all, :include => [ :account, :friends ]) person.find(:all, :group => "category")</pre>example for find with a lock: imagine twoconcurrent transactions: each will read <tt>person.visits == 2</tt>, add 1to it, and save, resulting in two saves of<tt>person.visits = 3</tt>. by locking the row, the second transaction hasto wait until the first is finished; we getthe expected <tt>person.visits == 4</tt>.
<pre> person.transaction do person = person.find(1, :lock => true) person.visits += 1 person.save! end</pre>
发表评论
-
HD2刷机的基础知识 HD2的radio、HSPL、ROM三种组合
2012-02-07 15:13 1100今天看着教程刚刷了台HD2,觉得有用的文章顺便转载过来 ... -
Hadoop配置部分内容
2012-02-04 15:29 741[size=medium;]Hadoop配置部分内容[ ... -
[转载]JPA 批注参考(1)
2012-02-04 11:39 725作为 Java 企业版 5 ... -
JVM 内存结构(转)
2012-02-03 14:49 900http://www.4ucode.com/Study ... -
JSP,PHP,Python,Ruby,Perl概要及各自特点
2012-01-31 15:18 994互联网技术日新月异,编程的语言层出不穷,原本稍微平静了 ... -
不要再浪费时间
2012-01-31 15:08 910不要再浪费时间 &l ... -
<<让oracle跑的更快1>>读书笔记2
2012-01-11 13:24 10231 绑定变量 1 ... -
Groovy Sql使用Spring的事务管理
2011-12-28 18:43 1287Grails如果不想用Hibernate的东东,可以直 ... -
Crack JRebel 4.0,无需重启JVM,热部署解决方案
2011-12-28 18:28 1170http://dl.dropbox.com/u/229 ... -
Linux tar压缩时排除某个目录或文件的参数
2011-12-21 13:48 1303在对某个目录进行压缩的时候,有时候想排除掉某个目录,例 ... -
2011面试题目之猴子偷桃
2011-12-21 11:14 1508<span style="" ... -
Qt 4.7.4 完美动态编译发布动态调试,以及静态编译发布
2011-12-20 14:53 1602首先是准备工作 ... -
C#信息采集工具实现
2011-12-20 12:34 918简单C#信息采集工具实现 最近想整只爬虫玩玩,顺便熟 ... -
介绍一个ASP.NET开发工具Web Matrix
2011-12-19 09:49 966想学习或者开发个小型的ASP.NET程序,装个VS.N ... -
程序名称DreamIT(梦想IT)提供许多IT公司的面试和笔试试题
2011-12-19 09:24 916<font style="bac ... -
基于SVG的WebGIS的一个雏形
2011-12-14 13:19 680我和一位师弟,经过了很多天的努力,终于做出了一个简单的 ... -
在Android中自定义IOS风格的按钮
2011-12-12 10:09 1096<p class="MsoNorm ... -
HTML5网站
2011-12-12 08:55 809记得刚来现在公司的时候,老大就说,作为移动平台部门的员 ... -
将字节流(byte[])转换成文件
2011-12-09 08:25 1523/** * 将字节流转换成文件 * @par ... -
在SUSE 11中安装Windows虚拟机
2011-12-09 01:29 899Novell公司最近推出 ...
相关推荐
在处理Oracle数据库查询时,ActiveRecord的查询接口使得SQL操作变得简单,如`.find`, `.where`, `.all`等。 部署是另一个关键环节。确保服务器环境也安装了必要的依赖,并正确配置了Oracle数据库连接。Rails应用...
@user = User.find_by(email: "john@example.com") ``` 更新用户信息: ```ruby @user.update(name: "Jane Doe") ``` 删除用户: ```ruby @user.destroy ``` 六、使用压缩包中的资源 "multiple_sqlite"这个...
如代码所示,我们先设定开始和结束日期,然后根据`params[:id]`获取员工ID,通过`Employee`模型的`find_with_timesheets_in_date_range`方法查询数据。 在`Employee`模型中,`find_with_timesheets_in_date_range`...
1. **参数化查询**:ActiveRecord的查询接口使用方法链,如`find_by`,`where`等,它们会自动处理SQL注入。你应该避免使用字符串拼接构建查询。 2. **白名单参数**:对用户输入进行验证,只允许特定格式的数据。 3...
在IT行业中,尤其是在Java开发领域,我们经常遇到各种运行时异常。"Nacos启动异常"是一个常见的问题,这里出现的具体异常是`java.lang.UnsatisfiedLinkError`,它通常发生在试图加载本地(C/C++)库时找不到相应的库...
template_for_shower 使用 Express 4 的 Node.js 应用程序,用于使用 Shower ( ) 构建演示文稿 在本地运行 确保您已安装 git clone ... cd template_for_shower npm install npm start 您的应用程序现在应该在上...
4. **循环右移指令(ROR)**:在指定范围内循环右移数值。 ### 数据选择与比较指令 1. **选择指令(SEL)**:根据条件选择两个数值中的一个。 2. **最大值指令(MAX)**:返回两个数值中的最大值。 3. **最小值...
TBL_FIND(Table Find表格查找)**: 表查找。用于在指定的表格中查找特定的数据项。 #### 八、数据转换指令 **64. BCD_I(Binary Coded Decimal_I二进制编码的十进制)**: BCD码转整数。用于将BCD编码转换为整数格式...
- **循环指令**:如ROL(循环左移)和ROR(循环右移)。 - **移位指令**:如SFTL(左移)和SFTR(右移)。 - **位处理指令**:如BIT_SET(置位)。 - **数据处理指令**:如ADD(加法)。 - **结构体创建指令**:如...
20.1.5 改进的findBy 245 20.2 对插件系统的改进 245 20.3 数据绑定 245 20.4 在GSP中使用JSP的标签 246 20.5 加密配置文件中的数据库密码 246 20.6 本章小结 246 参考文献 247 索引 248 Grails技术精解与Web...
- `find_all`: 查找所有符合条件的元素。 - `grep`: 匹配元素。 - `include?`: 包含元素。 - `max`: 获取最大值。 - `min`: 获取最小值。 - `reject`: 拒绝符合条件的元素。 - `sort`: 排序元素。 #### 三、...
**PowerPro** 的外部指令主要由不同的库提供,这些指令能够实现更高级的功能,如字符串处理、位操作、版本信息查询等。 ##### 1. 字符串处理指令 - **结合字符串指令 (CONCAT)**:连接两个或多个字符串。 - **删除...
- **移位和循环移位指令**:如SHL(左移),SHR(右移),ROL(循环左移),ROR(循环右移)。 2. **置位域/复位域指令**: - S指令用于置位,将指定的地址范围设为1。 - R指令用于复位,将指定的地址范围设为0...
例如,`Book.find_by(title: '某书名')`会查找标题为指定值的书籍。 9. ** erb模板** ERB(Embedded Ruby)是Rails视图中常用的模板引擎,可以插入Ruby代码到HTML中。例如,`<%= @book.title %>`会显示书籍的标题...
[3078995] ROL/ROR/SHL/SHR modeling wrong when dest reg is 32 bit [2864794] BX_INSTR_OPCODE in "cpu_loop" causes crash in x86_64 host [2884071] [AIX host] prefetch: EIP [00010000] > CS.limit [0000...
RCR 6.6.3.3 - ROL 6.6.3.4 - ROR 6.6.4 - The Bit Operations 6.6.4.1 - TEST 6.6.4.2 - The Bit Test Instructions: BT, BTS, BTR, and BTC 6.6.4.3 - Bit Scanning: BSF and BSR 6.6.5 - ...