示例#1
0
 /**
  * return the id, name, timestamp, and count of the number of people of all of the trees for user
  *
  * @param string $userName user name
  * @return unknown
  */
 public static function getFamilyTrees($userName, $includeCount = false, $db = null)
 {
     $familyTrees = null;
     if (!$includeCount) {
         $familyTrees = FamilyTreeUtil::getFamilyTreesFromCache($userName);
     }
     if (!is_array($familyTrees)) {
         if (is_null($db)) {
             $db =& wfGetDB(DB_SLAVE);
         }
         $db->ignoreErrors(true);
         $sql = 'SELECT ft_tree_id, ft_name, ft_owner_last_opened_timestamp, ft_checked' . ($includeCount ? ', (SELECT count(*) FROM familytree_page WHERE fp_tree_id = ft_tree_id) AS cnt' : '') . ' FROM familytree WHERE ft_user = '******'getFamilyTrees');
         $errno = $db->lastErrno();
         if ($errno > 0) {
             return null;
         }
         $familyTrees = array();
         while ($row = $db->fetchObject($rows)) {
             $familyTrees[] = array('id' => $row->ft_tree_id, 'name' => $row->ft_name, 'timestamp' => $row->ft_owner_last_opened_timestamp, 'checked' => $row->ft_checked, 'count' => $includeCount ? $row->cnt : 0);
         }
         $db->freeResult($rows);
         if (!$includeCount) {
             FamilyTreeUtil::setFamilyTreesCache($userName, $familyTrees);
         }
     }
     return $familyTrees;
 }