I have a query related question

Discussion in 'Off-Topic' started by ex-vber, Feb 11, 2012.

  1. ex-vber New Member

    I have recently purchased a couple of xenforo license and I am looking forward to convert my forums. I have some mods that I am using at vb which are very important to my forum and I or better said my co-admin who knows some php is trying to make them work for xenforo. He is stuck at the query part. In vb is like this

    Code:
    $query = $vbulletin->db->query_read_slave(" vb query is here "); 
    		if ($vbulletin->db->num_rows($query ) ) 
            { 
    		the vb code is here;
    		}
    We have tried the guide here at xenforo but it is not working.

    http://xenforo.com/community/threads/mysql-queries-how-to-use-db-in-xenforo-small-notes.5444/

    Any help would be much appreciated and we will show out appreciation for your time and help with a donation.

    Thank you.
  2. Robbo Staff Member

    I don't think there is currently any slave support. I'm not sure.
    Also I don't think there is a num_rows equivalent. You would just try and fetch a row instead. So...
    Code:
    if (XenForo_Application::get('db')->fetchRow($query))
    {
    	the code here;
    }
    ex-vber likes this.
  3. ex-vber New Member

    Thank you for your reply. We tried it without success. We used $db->fetchAll and $db->fetchRow for the queries but no joy. Is there anyother function that we should use to query the database?
  4. Robbo Staff Member

    What are the errors you are getting? Could I see the code you tried?
    ex-vber likes this.
  5. ex-vber New Member

    We did not got any error but it did not work. We tried these queries.

    Code:
    $query = $db->query("here the query");
    			if (XenForo_Application::get('db')->fetchRow($query))
    {
    	code here
    }
            }
    
    
    $query = $db->fetchAll("here the query");
    			if (XenForo_Application::get('db')->fetchRow($query))
    {
    	code here
    }
            }

    What we are trying to do is to search all the users tables for the emails and if a user is registered again with the same email he will get a message.
  6. Robbo Staff Member

    The query you send to fetchRow needs to simply be a string query. $db->query is running a full one query the same as the rest...

    So,
    Code:
    if ($db->fetchRow("here the query")) { code here } 
    ex-vber likes this.
  7. ex-vber New Member

    Thank you again. I will pass it along to my other admin that knows a little coding and report back.

Share This Page