[Tutorial] MySQL - a general guide.
#1

Hi and good evening ,
Actually suggested that I make one complete guide for MySQL , then we start?

Table of Contents:

# Open Table.
# Connect to .
# Queries.
# List of functions .
# Systems for example.

-----

Open Table :

First thing downloaded wamp official website ( this can be done by database site , and home storage ) .



Then all turned DOWNLOAD bar ,



And just click on the most modern version , and by your Huweindos bit .

Now turn on the wamp , if it is not running , and you have Skype on, get out of Skype rules , operate , and then try again to Skype .
Now enter the following address ,
[PHP ] localhost / phpmyadmin [ / PHP]
Excellent you entered ?
The following page will appear to you ,

Write in the field, Username , write "root " , and the Password field , leave blank.
Now will you next page ,

Press up on the bar on Databases ,

Now this page you beauty ,

You will find on this,

And under where it says , Create database , write the name of the table , it's actually called ' folder ' library files.
And where it appears Collaction Descend down and ran utf8_unicode_ci because it will not create bugs with the Hebrew language.
Then on the create .
And the table shows you the navigation bar on the left,

It finished that part, now it's part of the codes.

Connect to :

First thing you can do Difein the details, make optional .
[PHP] # define DB_USER "root"
# define DB_IP "localhost"
# define DB_TABLE "accounts"
# define DB_PASS "" [/ PHP]
The DB_USER , username root , default .
The DB_IP , Ipe of the server it is in the table.
DB_TABLE , table name.
DB_PASS , user password MySQL on wamp , no password.
Now you can compare the global variable connection ,
Up mode ,
[PHP] new gConnection; [/ PHP]
Now in OnGameModeInit ,
[PHP] gConnection = mysql_connect (DB_IP, DB_USER, DB_TABLE, DB_PASS); [/ PHP]
It is now possible to make some uses,
[PHP] mysql_num_rows (gConnection); [/ PHP]
Basically it takes the values ​​of the rows that are in tables, database equatorial gConnection .

-----

Queries:

# SELECT .
# WHERE .
# INSERT .
# OR.
# AND .
# UPDATE .
# DELETE.

SELECT

Hey this is actually really query selects values ​​kind of table is opened though you are choosing .
[PHP ] SELECT ` value ` FROM ` key ` [ / PHP]
Actually we chose the value, key in the table , will provide an example different
[PHP ] SELECT ` name ` FROM ` accounts ` [ / PHP]
Actually we chose the name kind of table accounts .
I will give another example ,
[PHP ] SELECT * FROM ' accounts ' [ / PHP]
Here basically it takes all the values ​​, if guests want to take some values ​​do so ,
[PHP ] SELECT ` name ` , ` password ` , ` kills ` FROM ` accounts ` [ / PHP]
Here basically it takes the values ​​name, paassword, kills, Table accounts .
Now another example ,
[PHP] SELECT `ID` FROM `accounts` WHERE `username` = 'iRaiDeN' [/ PHP]
Basically it will select the ID, Table accounts , where the name iRaiDeN .
The query WHERE learn now.

WHERE

Now this query actually turns where you want where in X.
I'll give an example,
[PHP] SELECT `password` FROM `accounts` WHERE `username` = 'iRaiDeN' [/ PHP]
As above, basically selects the password , where the accounts table , and where in the username iRaiDeN .

INSERT
Action actually brings to the table values ​​we want ,
[PHP] INSERT INTO `accounts` (`username`, `password`, `kills`, `death`) VALUES ('iRaiDeN', '123 ', 0,0) [/ PHP]
Actually added a table of values ​​accounts the values ​​username , password , kills , death , and each was given its own value .

OR

This one actually function really mean "or" I will give an example to illustrate this,
[PHP] SELECT `password` FROM `accounts` WHERE `username` = 'iRaiDeN' OR `username` = 'OzSasson' [/ PHP]
This basically selects the password , accounts table , where the name iRaiDeN , or if the name is OzSasson .

AND

Query This one says " well " , in addition, give an example and explained ,
[PHP] SELECT `password` FROM `accounts` WHERE `username` = 'iRaiDeN' AND `ID` = '2 '[/ PHP]
We selected the password table the accounts , where the username value , equal to iRaiDeN , and was also the ID equal to 0 .

UPDATE

It is actually a query to update the values ​​you are satisfied , I'll give an example to illustrate ,
[PHP] UPDATE `accounts` SET ID =% d WHERE `username` = 'iRaiDeN', playerid [/ PHP]
It is actually updating the table the ID of the player , and where in the name iRaiDeN .

DELETE

This is actually kind of query to delete the entry table / database , see example ,
[PHP ] DELETE FROM ` accounts ` [ / PHP]
This will delete all rows Gender foundation , if you want to delete the values ​​only from one user did it , so that ,
[PHP] DELETE FROM `accounts` WHERE `username` = 'iRaiDeN' [/ PHP]
Basically it will erase all the values ​​are the field of iRaiDeN .

I have just a few comments,
* Do it , ' entries .
* And - ` ` to a field / table / database .
* Obligated to write the queries only in large .

-----

List of functions :

[PHP] mysql_debug [/ PHP]
Actually Create the file mysql_log.txt .
Example ,
[PHP ] mysql_connect ( " localhost " , "root " , "table " , " 123 " ) ;
mysql_debug (1); [/ PHP]

[PHP ] mysql_connect [ / PHP]
This function actually connects to by individuals ,
[PHP ] mysql_connect ( " localhost " , "root " , "table " , " 123 ) [ / PHP]
Or you can also compare it to a variable , then do it uses,
Up mode ,
[PHP] new gConnection; [/ PHP]
The Public OnGameModeInit ,
[PHP] gConnection = mysql_connect ("localhost", "root", "table", "123 [/ PHP]
Then in use,
[PHP] mysql_num_row (gConnection); [/ PHP]
You have a reason to top ^ ^ .

[PHP] mysql_close [/ PHP]
Closing the database connection , you can connect an example of closing the foundation , from the equatorial variable ,
[PHP] mysql_close (gConnection); [/ PHP]

[PHP] mysql_ping [/ PHP]
Ping test basically the foundation , give an example,
[PHP] if (mysql_ping ()) print ("MySQL connection is still alive!");
if (! mysql_ping ()) print ("MySQL connection is dead!"); [/ PHP]
Basically if you have a ping , it sends a message that the foundation works, but if you do not ping it means that the foundation does not work .

[PHP] mysql_stat [/ PHP]
Taking Hststiskot of the foundation , for example,
[PHP] new gStat [150];
mysql_stat (gStat);
print (gStat); [/ PHP]
And on top of DOS ,
But such beauty Hststiskot different
[PHP ] Uptime : 380 Threads: 1 Questions : 3 Slow queries : 0 Opens : 12 Flush tables : 1 pen tables : 6 Queries per second avg : 0.008 [ / PHP]

[PHP] mysql_set_charset [/ PHP]
Change the connection, Collaction .
Example ,
[PHP] mysql_set_charset ("utf8_unicode_ci"); [/ PHP]

[PHP] mysql_get_charset [/ PHP]
Extraction connection ( Collaction ) , for example,
[PHP] new gCharset [20];
mysql_get_charset (gCharset); [/ PHP]

[PHP] mysql_reconnect [/ PHP]
Secondly database connection , for example,
[PHP] if (! Mysql_ping (gConnection)) mysql_reconnect [/ PHP]

[PHP] mysql_reload [/ PHP]
Reload values ​​.

[PHP] mysql_format [/ PHP]
Actually creating the following format suction can do that and more.
There's so useful , takes use of the function , Mysql_escape_string % e
String % s
Normal number % d
Decimal number % f
Integer % i


And just make him Queries ^ ^ ( up in ) .

[PHP ] mysql_query [ / PHP]
Here in fact putting values ​​and more into the table / database , for example,
[PHP] new szString [120];
format (szString, 120, "INSERT INSTO` accounts `(` username `) VALUES ('iRaiDeN')
mysql_query (szString); [/ PHP]
Here basically income into a new table , the value of username , equal to iRaiDeN ( all written above) .

[PHP] mysql_query_callback [/ PHP]
Here actually create a query, and call Public , as settimer .
Example ,
[PHP] forward MySqlCallback (query [], index, extraid, connectionHandle);
public OnPlayerConnect (playerid)
{
****mysql_query_callback (playerid, "SELECT * FROM` mybuildings `", "MySqlCallback");
}

public MySqlCallback (query [], index, extraid, connectionHandle)
{
****/ / Query processed, you can execute your code now
}
[ / PHP]
Credit to Samp - Wiki .

[PHP ] mysql_store_result [ / PHP]
If it is considered as an open " building " after the query.

[PHP ] mysql_free_result [ / PHP]
Which is the opposite wheel come full considered " building ."

[PHP ] mysql_real_escape_string [ / PHP]
Basically here keeping special characters such as , \ x00, \ n, \ r, \, ', "and \ x1a.

[PHP ] mysql_errno [ / PHP]
Taking damn and do something with it , manipulate re- foundation and more ...

[PHP] mysql_warning_count [/ PHP]
Taking multiple Hwarningim we had before ...

[PHP ] mysql_affected_rows [ / PHP]
Taking only the things most affected rows.

[PHP] mysql_num_fields [/ PHP]
Returns the number of fields , for example,
[PHP] mysql_query ("SELECT field1, field2, field3 FROM table2"); mysql_store_result (); printf ("% d fields were selected.", Mysql_num_fields ()); mysql_free_result (); [/ PHP]
Credit to Samp - Wiki .

-----

Systems eg

Credit to Palvin - Enosh.
Fastbin .
* The system just for learning.

In conclusion I want to say a few things , the things posted here is part of sex guides I've posted here , and I just did a general guide , has been on everything and that's it, and I gave credit to those who need .
Any help HF .
Reply
#2

Quote:
Originally Posted by iRaiDeN
Посмотреть сообщение
Huweindos bit .
What's that?
Reply
#3

Quote:
Originally Posted by Kikito
Посмотреть сообщение
What's that?
Hey, it's tranlate from hebrew tutorial, I published another forum.
Quote:
Originally Posted by ******
Посмотреть сообщение
You realise that using the root user for everything with no password is just begging to be hacked right? The first thing I do is create two new accounts - one with only create and modify table privileges, and another with SELECT/INSERT/UPDATE. I use the second in modes, the first just to create tables in advance, and lock down "root" as much as possible to minimise SQL injection vectors.
Okay.
Reply
#4

I hope you take a fast look at your main post and see how ugly it is.
Reply
#5

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
I hope you take a fast look at your main post and see how ugly it is.
That, it isn't really attractive to be read.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)