CodeIgniter NOW()insert:什么是最快的方法? [英] CodeIgniter NOW() insert: what's the fastest way?
问题描述
什么代码会更快(或更好):
What code will be faster (or better):
$this->db->set('date', 'NOW()', FALSE);
或
$data['date'] = date('Y-m-d H:i:s');
推荐答案
高架。但我不会说PHP中的函数调用非常昂贵,因为 qwertzman回答。 Ok它可能比其他语言慢,但这真的不是重点。查看此比较与1,000,000函数调用。
In general all function calls will be slower because of the overhead. However I won't say function calls in PHP are very expensive as qwertzman answered. Ok it may be slower compared to other languages, but that really isn't the point. Have a look at this comparison with 1,000,000 function calls. You see what you gain?
当谈到哪一段代码更快时(在你的OP中)你在谈论微优化,而且真的是一些您不应该担心< a>。
When talking about which piece of code is faster (in your OP) you're talking about micro-optimization and is really something you shouldn't have to worry about.
真正的问题是哪段代码是:更好的可维护性,可读性,可理解性。
The real question is which piece of code is: better maintainable, readable, understandable.
这篇关于CodeIgniter NOW()insert:什么是最快的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!