Raised This Month: $ Target: $400
 0% 

SQL_TableExists help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 08-31-2009 , 17:32   SQL_TableExists help
Reply With Quote #1

Heya
This appears to work, but does any1 know any way to make it better?
its a bit sloppy atm and i wanna clean it up
PHP Code:
bool:SQL_TableExists(szTable[])
{
    new 
Handle:SqlConnection SQL_Connect(gSqlTupleErrorCodegError511);
    
    if(
SqlConnection == Empty_Handle)
    {
        
set_fail_state(gError);
    }
    
    new 
Handle:Query;
    new 
iOutput;
    
    
Query SQL_PrepareQuery(SqlConnection"SELECT * from `%s`"szTable);
    
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QuerygError511);
        
        if(
containi(gError"#1146") != -1)
        {
            
iOutput 0;
        }
        else if(
containi(gError"No result set in this query!") != -1)
        {
            
iOutput 0;
        }
    }
    else
    {
        
iOutput 1;
    }
    
    
SQL_FreeHandle(Query);
    
SQL_FreeHandle(SqlConnection);
    
    return 
iOutput == true:false;

__________________

Last edited by minimiller; 08-31-2009 at 18:10. Reason: fix't
minimiller is offline
Send a message via MSN to minimiller
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode