• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved how to correctly call query

arheon

Own3d PlAx.'?
Joined
Aug 31, 2009
Messages
92
Reaction score
3
[SOLVED]
Noobish question but anyway there i go :
I want to call query and if there's no such row (return 0) then function returns false and if there's row then function returns true
But somehow i keep getting :
Code:
Result not Set
From every function i use from 04-database.lib (getRows,getDataInt,etc)

Example :
Lua:
function accountStorageExists(cid,key)
	local storage = db.getResult("SELECT * FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid)  .. "' and `key` = '" .. key .. "');")
	local rows = storage:getRows()
	if rows == 1 then return true else return false end
end
This one gives error [Result:getRows] Result not set !
Query works correctly in phpmyadmin -> SQL (It doesn't return error)
 
Last edited:
Easier example :
I need function like that(sucessfulQuery) :
PHP:
	/* QUERY DOESN'T HAVE IMPORTANCE */
        $query = mysql_query("SELECT FROM accounts WHERE id='1'");
      
       /* I NEED THAT FUNCTION IN LUA : */
	function sucessfulQuery($q) {
	$numrows=mysql_num_rows($q)
		if ($numrows == 1) {
			return true;
		else
			return false;
		}
	}
        
        /* NOW WHEN I RUN FUNCTION ON QUERY IT GIVES TRUE OR FALSE */
	sucessfulQuery($query);
but in LUA working under 0.3.6 or 0.4.
This function would give true if there would be account with ID 1.
If there would be no account with ID 1 then it would give false.

@ i need to know how to do something like that but in LUA , cause all my tries have failed
 
try this
Lua:
function accountStorageExists(cid,key)
	local storage = db.getResult("SELECT `id` FROM `accounts_storage` WHERE (`id` = " .. getPlayerAccountId(cid) .. " and `key` = " .. key .. ");")
	if(storage:getID() == -1) then
		return false
	end
	return true
end
 
[SOLVED]

Nice sir , working perfectly. Rep++
try this
Lua:
function accountStorageExists(cid,key)
	local storage = db.getResult("SELECT `id` FROM `accounts_storage` WHERE (`id` = " .. getPlayerAccountId(cid) .. " and `key` = " .. key .. ");")
	if(storage:getID() == -1) then
		return false
	end
	return true
end
 
Back
Top