Loading nodes from a specific user and a specific node type I have written this function to do so, but it behave strangly, i am wondering if i have the correct approach 

function getNodes($type,$userID){
        $where = array();   
        $nodes = array();
        $where[':type'] = $type;
        $where[':uid'] = $userID;
        $result = db_query('SELECT nid FROM {node} WHERE uid = :uid AND type = :type', $where);
        if($result){
            foreach($result as $o){
                $nodes = node_load($o-&gt;nid);
            }
        }
    return $nodes;
}


Isn't there a drupal API that loads node from the DB by passing it a UID and Node type ?
In D6 you could pass criteria to node_load(), so you could do 

 $criteria = array(
   'uid' =&gt; $userID,
   'type' =&gt; $type,
 );

 $nodes = node_load($criteria);


would do the job. 

In D7, you don't have this option with node_load as it is just a wrapper for entity_load. This has a depricated argument which allows you to load nodes in the same way

 $criteria = array(
   'uid' =&gt; $userID,
   'type' =&gt; $type,
 );

 $nodes = entity_load('node',FALSE,$criteria);


note untested

This may work, but is not guaranteed to.

The approved way to do this in D7 is to use EntityFieldQuery

  $query = new EntityFieldQuery();
  $entities = $query-&gt;entityCondition('entity_type', 'node')
    -&gt;entityCondition('bundle', $type)
    -&gt;propertyCondition('uid', $userID)
    -&gt;execute();        
  $nodes = node_load_multiple(array_keys($entities['node']));   


note also untested