1. The more I use Drupal 7….

    ….The more I LOVE! it. 

    The database abstraction layer is truly fantastic!  It already was in Drupal 7 but they’ve definately made it more dynamic in 7. Love it! Check out this example where I’m creating a fairly straightforward, but not simple, query. In this query I’m pulling from one table and joining 2 more with all kinds of conditions and ordering logic. I can add or take away very quick without having to mine through a monster query!

    $example_prepare = db_select('example', 'a');
    $example_prepare->leftJoin('example_one', 'b', 'a.nid = b.nid');
    $example_prepare->leftJoin('example_two', 'c', 'c.nid = a.nid');
    $example_prepare->fields('a')
    		->fields('b', array('title','created'))
    		->fields('c',array('blahblah'))
    	 	->condition('a.created',$dateRange['value'],'>=')
    	 	->condition('a.created',$dateRange['value'],'<=')
    	  	->orderBy('a.created', 'ASC')
    	  	->orderBy('c.blahblah')
    	  	->orderBy('b.title');
    		  	
    $example = $example_prepare->execute();
    
     
    1. revjtanton posted this