SphereCommunity
mySQL problem - db.row - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: mySQL problem - db.row (/Thread-mySQL-problem-db-row)



mySQL problem - db.row - Eledrianek - 09-11-2014 12:57 PM

Hi,
can anyone help me with little mysql problem?

This works:
Code:
DB.QUERY "SELECT COUNT(*) FROM kelevar_quests_stats"
        local.kolik=<db.row.0>
        FOR <local.kolik>
        DB.QUERY "SELECT prijato FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        local.prijato=<db.row.0>
        DB.QUERY "SELECT splneno FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        local.splneno=<db.row.0>
        DB.QUERY "SELECT preruseno FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        local.preruseno=<db.row.0>
        DB.QUERY "SELECT ID_questu FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        DB.QUERY "SELECT * FROM kelevar_quests_stats WHERE id='<dlocal._for>'"

But this one not (it result to debug and show only db.row.1)
Code:
        local.name=<DEF.QUEST_<argn1>_NAMELOCALIZED>
        DB.QUERY "SELECT COUNT(*) FROM kelevar_quests_stats"
        local.kolik=<db.row.0>
        FOR <local.kolik>
        DB.QUERY "SELECT * FROM kelevar_quests_stats WHERE id='<dlocal._for>'"
        dtext 95 <eval 60+(<dlocal._for>*20)> 88 <def.quest_<db.row.1>_namelocalized>
        dtext 370 <eval 60+(<dlocal._for>*20)> 44 <db.row.2>
        dtext 430 <eval 60+(<dlocal._for>*20)> 44 <db.row.3>
        dtext 490 <eval 60+(<dlocal._for>*20)> 44 <db.row.4>
        local.x +=1
        endfor

This shorter code results to this:
Code:
04:57:DEBUG:__ thread (3048) __ |  # | _____ function _____________ | ticks passed from previous function start ______
04:57:DEBUG:>>         3048     |  0 | NetworkManager::processAllInput | +0
04:57:DEBUG:>>         3048     |  1 |   NetworkInput::processInput | +0
04:57:DEBUG:>>         3048     |  2 |    NetworkInput::processData | +0
04:57:DEBUG:>>         3048     |  3 |    NetworkInput::processData | +0
04:57:DEBUG:>>         3048     |  4 | NetworkInput::processGameClientData | +0
04:57:DEBUG:>>         3048     |  5 | PacketGumpDialogRet::onReceive | +0
04:57:DEBUG:>>         3048     |  6 |     CClient::Dialog_OnButton | +0
04:57:DEBUG:>>         3048     |  7 |  CScriptObj::OnTriggerRunVal | +0
04:57:DEBUG:>>         3048     |  8 |     CScriptObj::OnTriggerRun | +0
04:57:DEBUG:>>         3048     |  9 |                CChar::r_Verb | +0
04:57:DEBUG:>>         3048     | 10 |             CObjBase::r_Verb | +0
04:57:DEBUG:>>         3048     | 11 |        CClient::Dialog_Setup | +0
04:57:DEBUG:>>         3048     | 12 |        CDialogDef::GumpSetup | +0
04:57:DEBUG:>>         3048     | 13 |  CScriptObj::OnTriggerRunVal | +0
04:57:DEBUG:>>         3048     | 14 |     CScriptObj::OnTriggerRun | +0
04:57:DEBUG:>>         3048     | 15 |     CScriptObj::OnTriggerRun | +0
04:57:DEBUG:>>         3048     | 16 | CScriptObj::OnTriggerForLoop | +16
04:57:DEBUG:>>         3048     | 17 |     CScriptObj::OnTriggerRun | +1719
04:57:DEBUG:>>         3048     | 18 |           CDialogDef::r_Verb | +0
04:57:DEBUG:>>         3048     | 19 |                CChar::r_Verb | +0
04:57:DEBUG:>>         3048     | 20 |             CObjBase::r_Verb | +47
04:57:DEBUG:>>         3048     | 21 |           CScriptObj::r_Verb | +0 <-- exception catch point (below is guessed and could be incorrect!)
04:57:DEBUG:>>         3048     | 22 |                CGFile::Close | +0
04:57:DEBUG:command 'DB.QUERY' args '"SELECT * FROM kelevar_quests_stats WHERE id='20'' [231AF63C]

How this thing works? Is it possible to extract all information from the mySQL table? Thanks for any help...


RE: mySQL problem - db.row - Extreme - 09-11-2014 02:36 PM

Hi!

Could you give more information?
Like a printscreen of your table and what data you want to get from it.


RE: mySQL problem - db.row - Eledrianek - 09-11-2014 09:00 PM

This is the screen of my table kelevar_quests_stats. MySQL access and reading column just one by one (im able to access to the data from "ID_questu" "prijato" etc but not all in one QUERY.

Is there a way how sphere could read whole this table and use its informations in the script?

Or I must use scp like this, with multiple QUERIES:
Code:
//DB.QUERY "SELECT prijato FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        //local.prijato=<db.row.0>
        //DB.QUERY "SELECT splneno FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        //local.splneno=<db.row.0>
        //DB.QUERY "SELECT preruseno FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"
        //local.preruseno=<db.row.0>
        //DB.QUERY "SELECT ID_questu FROM kelevar_quests_stats WHERE ID='<dlocal._for>'"

[Image: L9Y0f.jpg]


RE: mySQL problem - db.row - Eledrianek - 09-12-2014 12:19 AM

Ok.... I rework this to show data in the web, so I dont need this anymore. But answer should be interesting for someone else.

I have another questions related to this - is there any way how I can send variables to the mySQL with unicode? I have huge problem with symbols like that - ěščřžřžýáýéíá - which we use normaly in our language. I cant find a way... Shock(


RE: mySQL problem - db.row - Extreme - 09-12-2014 12:53 AM

To get all columns, use this:

DB.QUERY SELECT * FROM TABLE_NAME WHERE ID_questu='x'

It will return whole data found with ID_questu='x'
The number of rows found is <DB.ROW.NUMROWS>
To access a specific column: <DB.ROW."RowNumber"."ColumnName">
Example: <DB.ROW.0.PRIJATO> will return the value on column 'prijato' of the line '0'

Not sure about the unicode thing, but you need to change some settings on database.
You can find a lot of help in google.