[Plugin] [REL] MySQL Plugin (Now on github!)

Quote:
Originally Posted by Baltimore
Посмотреть сообщение
Hello!

MySQL R39-2, when doing an INSERT INTO, we do not specify the id.

Is it possible to force to use a specific id?

Ex: Force to insert a line with a given id.
It's possible for other things using MySQL. But there's no function for it in "BlueG's MySQL Plugin".
Reply

I have seen the milestones for R40, but is there an approximate date as to when it'd be released ?
Reply

Quote:

mysql_fetch_row_format

Description:
Use this function to fetch whole row from the result set.

Image:32px-Ambox_warning_orange.png
Note
This function also moves the internal row pointer to the next row.

Okay, so till R6/7 mysql_fetch_row_format would be used to move the internal pointer to the next row.
My question is what code would we implement to replace the functioning of mysql_fetch_row_format in R39-2 ? OR is there any similar function since mysql_fetch_row_format is no more.
Reply

You can now access every row independently by its index through cache_get_row and cache_get_field_content.
What was
Код:
new data[4];
new row_data[128];
while(mysql_fetch_row_format(row_data))
{
    sscanf("p<|>...", data[0], data[1], ...);
}
is now
Код:
new data[4];
for(new r=0; r < cache_num_rows(); r++)
{
    data[0] = cache_get_row_int(r, 0); //store the first field (index '0') into data[0]
    data[1] = cache_get...
}
Reply

When the plugin loses the connection with the server, and reconnects, is it possible to check if the reconnection was successful or not?

SAMP server locks itself automatically, when there's a connection error, and i want to open the server when the MySQL connection is OK.
Reply

If I use orm_save or orm_update and only 1 variable out of 5 was changed in the enumerator, does it updates all the variables or only the specific one that was changed?
Reply

All registered variables are updated.
Reply

I haven't been up to date with relases for quite long time. With latest release for some reason inline responses are doubled?

pawn Код:
#include <a_samp>

#define MYSQL_USE_YINLINE
#include <a_mysql>

new dbhandle;

forward Qt();
public Qt() {
    print("Public instead");
}

public OnGameModeInit() {
    dbhandle = mysql_connect("localhost", "root", "samp_733", "");

    inline Fetch() {
        printf("Inline");
    }

    mysql_tquery_inline(dbhandle, "SELECT 2 + 2 AS foobar FROM dual", using inline Fetch, "");
    mysql_tquery(dbhandle, "SELECT 2 + 2 AS foobar FROM dual", "Qt", "");

    return 1;  
}

main() {
    print("Hello");
}
Using latest YSI.

Quote:

[11:26:03] Hello
[11:26:03] Number of vehicle models: 0
[11:26:03] Inline
[11:26:03] Inline
[11:26:03] Public instead

Reply

If I use cache_get_field_content_int on an INT field which can be null it says invalid data type.

I came up with this:
pawn Код:
new tmp[32];
cache_get_field_content(0, "IntField",tmp);
place_where_i_want_to_put_it = (ismysqlnull(tmp)) ? (some int value) : (strval(tmp));
But this doesn't feel nice, especially when I need to process more than few fields like this.

Is there a more elegant sollution?
Reply

'0' and 'NULL' aren't the same values. A numeric field can be '0' or 'NULL' (if allowed), it would destroy the whole point of 'NULL's existence if they were both treated as one and the same. The plugin and the MySQL C API treat '0' as a number and 'NULL' as a string, that's why you can't use cache_get_*_int with 'NULL' as value.
Take a look at the MySQL documentation here and this site and you'll see why it doesn't make sense to use 'NULL' as a numeric value.
Reply

I understand that they are completely different. I'm just asking for a easier way to check if it's null. Something like "is_field_null(row, const fieldname[])" would be nice.
Reply

Quote:
Originally Posted by dusk
Посмотреть сообщение
I understand that they are completely different. I'm just asking for a easier way to check if it's null. Something like "is_field_null(row, const fieldname[])" would be nice.
You can use the operator IS NULL to check if the value is NULL or not.

Код:
SELECT * FROM table_name WHERE field_name IS NULL
The above query will list the rows which got NULL value for the mentioned field.
Reply

Код:
bool:cache_is_field_null(row_idx, const field_name[])
{
	new dest[5];
	cache_get_field_content(row_idx, field_name, dest);
	return (strcmp(dest, "NULL") == 0);
}
Just use that function. No point in making that same function on the plugin-side.
Reply

When new version.
Reply

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
When new version.
Why do you need a new version?
Reply

Not right to say new version, but i need that authtor makes faster plugin queries and other stuff what there is in new version.
Reply

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
Not right to say new version, but i need that authtor makes faster plugin queries and other stuff what there is in new version.
We already have our best cryptologists trying to figure out what the * you said.
Reply

I need fast in new version.
Reply

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
I need fast in new version.
use dini then, its 420 blazing faster than MySQL
Reply

Quote:
Originally Posted by Banditukas
Посмотреть сообщение
I need fast in new version.
The plugin is already quite fast. Perhaps you're not using the threaded or parallel queries? Or maybe your queries simply suck?

The same in Lithuanian for you:
Pats plugin jau yra pakankamai greitas. Gal tu tiesiog nenaudoji threader ar parallel uћklausų? O gal tavo uћklausos tiesiog siaubingos?

Please do not respond in only Lithuanian.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)