Raised This Month: $51 Target: $400
 12% 

How to make copy of a mysql table to a config file (ini)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xJaw
Junior Member
Join Date: Mar 2017
Old 01-01-2019 , 09:26   How to make copy of a mysql table to a config file (ini)
Reply With Quote #1

I was trying to make copy of my db table but was not getting how can i loop through each row in the table and save that to my file can anyone show just this part of iterating through each row and getting values from there ??

For example : table name = EXAMPLE

EXAMPLE
--------------------
Name SteamId
xyz STEAM: xxxx
abc STEAM: xxxx

Last edited by xJaw; 01-01-2019 at 09:26.
xJaw is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-01-2019 , 11:48   Re: How to make copy of a mysql table to a config file (ini)
Reply With Quote #2

PHP Code:

SELECT 
FROM myTable ORDER BY OneOfTheFields

while ( SQL_MoreResultsquery ) )
{
   
SQL_ReadResultquery )
   
SQL_ReadResultquery )
   
//repeat for number of columns

   
Format output line "%s %s %s %s %s" Field1 Field2 Field3 Field4 Field5
   write to file the formatted line

   SQL_NextRow
query )

__________________
Bugsy is offline
xJaw
Junior Member
Join Date: Mar 2017
Old 01-02-2019 , 00:13   Re: How to make copy of a mysql table to a config file (ini)
Reply With Quote #3

Hello bugsy thanks for the info but i did exactly like this and read this tutorial too https://forums.alliedmods.net/showthread.php?t=132686

Here is my code and is still not working

PHP Code:
#include <amxmodx>
#include <sqlx>

new Host[]     = "localhost"
new User[]    = "root"
new Pass[]     = ""
new Db[]     = "sqltest"

new Handle:g_SqlTuple
new g_Error[512]


public 
plugin_init() {
    
register_plugin("PLUGIN""VERSION""AUTHOR")

    
set_task(1.5"Load_MySql")
}

public 
plugin_end()
    
SQL_FreeHandle(g_SqlTuple)

public 
Load_MySql()
{
    
g_SqlTuple SQL_MakeDbTuple(Host,User,Pass,Db)
    new 
errorCode
    
new Handle:sql SQL_Connect(g_SqlTupleerrorCodeg_Errorcharsmax(g_Error))

    new 
Handle:query
    
    
new foundEXP[10], foundSteam[33]

    
query SQL_PrepareQuery(sql,"SELECT * FROM `tutorial` ORDER BY `exp`")

    
server_print("STAGE 2")
    while(
SQL_MoreResults(query))
    {
        
server_print("STAGE 3")
        
SQL_ReadResult(query0foundSteamcharsmax(foundSteam))
        
SQL_ReadResult(query1foundEXPcharsmax(foundEXP))

        
server_print("%s EXP = %d"foundSteamstr_to_num(foundEXP)) // Just to view it in server console
        
SQL_NextRow(query)
    }

It never outputs STAGE 3 ..


Edit:
I even added this after the preparation of my query
PHP Code:
 server_print("Results %d"SQL_NumResults(query)) 
And it outputs "Results 0"

Even my Table has 2 Enteries in it

Last edited by xJaw; 01-02-2019 at 00:53. Reason: edit
xJaw is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-02-2019 , 03:40   Re: How to make copy of a mysql table to a config file (ini)
Reply With Quote #4

Read the tutorial again, you are missing steps. You didn't execute the query at all.
__________________
klippy is offline
Reply



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 20:35.


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