惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
U
Unit 42
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
L
LangChain Blog
Engineering at Meta
Engineering at Meta
量子位
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
A
About on SuperTechFans
Y
Y Combinator Blog

《轉個彎日誌》的留言

MVC是一個巨大誤會 RedBeanPHP 操作資料庫的好幫手 我現在就想用你的產品,就算破破的也請馬上給我用 框架不應該有「models」資料夾 MVC是一個巨大誤會 工程師的缺德行為:叫朋友去學C/C++ Rails之父:我怎麼學會寫程式的?
RedBeanPHP 操作資料庫的好幫手
2018-11-10 · via 《轉個彎日誌》的留言

最近發現一個很不錯的php ORM library
http://www.redbeanphp.com/quick_tour

我前陣子接某個case 連資料庫是這樣寫

$sql = ‘select * from category2’;
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
// do something on the $row
}

寫多了滿煩的

最近要幫客戶修改一些功能 找了RedBean來使用

套上之後變這樣
$types = R::find(‘category2’);
foreach ($types as $row){
// do something on the $row
}
省去了很多囉唆的程式碼

其實好用不是重點
重點是可以看原始碼練功

整個library僅僅是一個php檔
原始碼1萬2千行 切成幾十個class
用到OOP的繼承跟介面
每個class每個method內部程式碼都沒幾行 註解完整
也沒有複雜的巢狀條件判斷
如果說追新技術 追新工具算是勤學外功的話
研讀這些source code算是練內功吧

by 阿川先生