(2012-05-03, 01:41 PM)crazy4cs Wrote: [ -> ]As soon as I think about Yii, I see myself like an idiot who would know nothing in it. PHP was very easy, in fact, still learning it in deep.
All frameworks are just an interpretation of MVC and OOP in PHP. Some do it well and some do it like an episode of CSI.
Consider the following query builders:
// MyBB 1.6
// Requires escape_string
$query = $db->simple_select('users', 'uid, username, email', "username LIKE '%Tomm%' OR username LIKE '%labrocca%'");
// Code Igniter
$this->db->select('uid', 'username', 'email');
$this->db->like('username', 'Tomm');
$this->db->or_like('username', 'labrocca');
$query = $this->db->get('users');
// Laravel
// Not sure if wildcards require escaping
$query = DB::table('users')
->where('username', 'LIKE', array('%Tomm%', '%labrocca%'))
->get('uid', 'username', 'email');
// Yii
// Requires wildcard characters to be escaped before use
$query = Yii::app()->db->createCommand()
->select('uid', 'username', 'email')
->from('users')
->where(array('like', 'username', array('%Tomm%', '%labrocca%')))
->queryAll();
// Doctrine/Symfony
// $qb; createQueryBuilder instance
$query = $qb->select(new Expr\Select(array('u.uid', 'u.username', 'u.email')))
->add('from', new Expr\From('Users', 'u'))
->add('where', $qb->expr()->orX(
$qb->expr()->like('u.username', '?1'),
$qb->expr()->like('u.username', '?2')
))
->setParameters(array(1 => 'Tomm', 2 => 'labrocca'))
->getQuery();
// ... all produce
$query = "SELECT uid, username, email FROM mybb_users WHERE username LIKE '%Tomm%' OR username LIKE '%labrocca%'";
Apologies if any of the above is incorrect. All of it is PHP but is particular to the specific framework. It's worth noting that both Laravel and Yii require wildcards to be escaped before use and MyBB 1.6 will require escape_string.
As you can see, all 4 examples use a different method of querying the database with their own query builders. It's not that any of it is hard, alien or complex - it's just 100% different to what you're used to doing (perhaps, because this is the first framework experience?).
The more and more you delve into PHP's OOP and MVC methods the easier it is to understand what's going on within frameworks. It's easy to see the complexity grow between CI, Laravel, Yii then the impossible Doctrine but it's all about finding the happy medium for MyBB 2.0.