文章是从我的个人主页上粘贴过来的,
大家也可以访问我的主页 www.iwangzheng.com
今天在数据库里新增人员的时候出了点小问题,有人员重复了,以至于要删除一些,大师和pp指导完成的。
$rails c p
=>CmsUser.all
=>CmsUser.all.last
=>CmsUser.where("email = ?", 'shi')
=>CmsUser.where("email like ?",'%shi%').last
=>a=CmsUser.where("email like ?",'%shi%').last
=>a.destory
=>CmsUser.all.size
=>CmsUser.where('email not like ?', '%@%').size
=>CmsUser.where('email not like ?', '%@%')
=>CmsUser.where('email not like ?', '%@%').map(&:email)
=>CmsUser.where('email not like ?', '%@%').delete_all
=>CmsVideo.all.each_with_index{|v,i| v.update_attribute(“position”,i)}
=>
CmsModule.order(‘id asc’).each_with_index do |tv_module, index|
tv_module.update_attributes(:position => index)
end
=>CmsVideoInformation.where('video_id =?','6300').each{|v| v.update_attribute("last_episode_index","35")}