Skip to content

Commit 17bf7b7

Browse files
committed
168 translated functions for Persian
1 parent 4c59866 commit 17bf7b7

File tree

168 files changed

+10310
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+10310
-0
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
title: DB_GetFieldFloat
3+
sidebar_label: DB_GetFieldFloat
4+
description: محتوای یک فیلد رو به عنوان یک عدد اعشاری با ایندکس فیلد مشخص شده دریافت می‌کند.
5+
keywords:
6+
- sqlite
7+
tags: ["sqlite"]
8+
---
9+
10+
## توضیحات
11+
12+
این تابع محتوای یک فیلد رو به عنوان یک عدد اعشاری با ایندکس فیلد مشخص شده دریافت می‌کند.
13+
14+
| نام | توضیحات |
15+
| --------------- | ---------------------------------- |
16+
| DBResult:result | نتیجه‌ای که داده‌ها از اون گرفته میشه. |
17+
| field = 0 | فیلدی که داده‌ها از اون گرفته میشه. |
18+
19+
## مقدار بازگشتی
20+
21+
مقدار بازیابی شده به عنوان یک عدد اعشاری.
22+
23+
## مثال‌ها
24+
25+
```c
26+
// examples.inc
27+
28+
// ...
29+
30+
static FindFieldIndexByName(DBResult:dbResultSet, const fieldName[])
31+
{
32+
// Return value variable with default return value
33+
new ret = -1;
34+
35+
// Field count
36+
new field_count = DB_GetFieldCount(dbResultSet);
37+
38+
// Current field name
39+
new current_field_name[32];
40+
41+
// Iterate through all fields
42+
for (new field_index; field_index < field_count; field_index++)
43+
{
44+
// Get field name
45+
if (DB_GetFieldName(dbResultSet, field_index, current_field_name, sizeof current_field_name))
46+
{
47+
// Compare searched field name to current field name
48+
if (!strcmp(fieldName, current_field_name))
49+
{
50+
// Success, store field index to return value variable
51+
ret = field_index;
52+
53+
// Break out of the loop
54+
break;
55+
}
56+
}
57+
}
58+
59+
// Return found field index or "-1"
60+
return ret;
61+
}
62+
63+
Float:Examples_CalculateSum(DB:dbConnectionHandle)
64+
{
65+
// Return value variable
66+
new Float:ret;
67+
68+
// Database result set
69+
new DBResult:db_result_set = DB_ExecuteQuery("SELECT `value` FROM `examples`");
70+
71+
// If database result set is valid
72+
if (db_result_set)
73+
{
74+
// Get target field index
75+
new target_field_index = FindFieldIndexByName(db_result_set, "value");
76+
77+
// Check if field index is valid
78+
if (target_field_index >= 0)
79+
{
80+
// Do operations
81+
do
82+
{
83+
// Add value from "example" field to the return value variable
84+
ret += DB_GetFieldFloat(db_result_set, target_field_index);
85+
}
86+
87+
// While next row could be fetched
88+
while (DB_SelectNextRow(db_result_set));
89+
}
90+
91+
// Free result set
92+
DB_FreeResultSet(db_result_set);
93+
}
94+
95+
// Return calculated sum
96+
return ret;
97+
}
98+
```
99+
100+
```c
101+
// mode.pwn
102+
103+
// ...
104+
105+
#include <examples>
106+
107+
static DB:gDBConnectionHandle;
108+
109+
// ...
110+
111+
public OnGameModeInit()
112+
{
113+
// ...
114+
115+
// Create a connection to a database
116+
gDBConnectionHandle = DB_Open("example.db");
117+
118+
// If connection to the database exists
119+
if (gDBConnectionHandle)
120+
{
121+
// Successfully created a connection to the database
122+
print("Successfully created a connection to database \"example.db\".");
123+
printf("Calculated sum: %f", Examples_CalculateSum(gDBConnectionHandle));
124+
}
125+
else
126+
{
127+
// Failed to create a connection to the database
128+
print("Failed to open a connection to database \"example.db\".");
129+
}
130+
131+
// ...
132+
133+
return 1;
134+
}
135+
136+
public OnGameModeExit()
137+
{
138+
// Close the connection to the database if connection is open
139+
if (DB_Close(gDBConnectionHandle))
140+
{
141+
// Extra cleanup
142+
gDBConnectionHandle = DB:0;
143+
}
144+
145+
// ...
146+
147+
return 1;
148+
}
149+
```
150+
151+
## نکات
152+
153+
:::warning
154+
155+
استفاده از یک handle نامعتبر غیر از صفر سرور شما رو کرش می‌کنه! یک handle اتصال پایگاه داده معتبر رو با استفاده از [DB_ExecuteQuery](DB_ExecuteQuery) دریافت کنید.
156+
157+
:::
158+
159+
## توابع مرتبط
160+
161+
- [DB_Open](DB_Open): اتصال به پایگاه داده SQLite باز کنید
162+
- [DB_Close](DB_Close): اتصال به پایگاه داده SQLite بسته کنید
163+
- [DB_ExecuteQuery](DB_ExecuteQuery): پایگاه داده SQLite رو کوئری کنید
164+
- [DB_FreeResultSet](DB_FreeResultSet): حافظه نتیجه رو از DB_ExecuteQuery آزاد کنید
165+
- [DB_GetRowCount](DB_GetRowCount): تعداد سطرهای یک نتیجه رو دریافت کنید
166+
- [DB_SelectNextRow](DB_SelectNextRow): به سطر بعدی بروید
167+
- [DB_GetFieldCount](DB_GetFieldCount): تعداد فیلدهای یک نتیجه رو دریافت کنید
168+
- [DB_GetFieldName](DB_GetFieldName): نام یک فیلد در ایندکس مشخص رو برگردونه
169+
- [DB_GetFieldString](DB_GetFieldString): محتوای فیلد با ID مشخص از سطر نتیجه فعلی رو دریافت کنید
170+
- [DB_GetFieldStringByName](DB_GetFieldStringByName): محتوای فیلد با نام مشخص از سطر نتیجه فعلی رو دریافت کنید
171+
- [DB_GetFieldInt](DB_GetFieldInt): محتوای فیلد به عنوان عدد صحیح با ID مشخص از سطر نتیجه فعلی رو دریافت کنید
172+
- [DB_GetFieldIntByName](DB_GetFieldIntByName): محتوای فیلد به عنوان عدد صحیح با نام مشخص از سطر نتیجه فعلی رو دریافت کنید
173+
- [DB_GetFieldFloat](DB_GetFieldFloat): محتوای فیلد به عنوان عدد اعشاری با ID مشخص از سطر نتیجه فعلی رو دریافت کنید
174+
- [DB_GetFieldFloatByName](DB_GetFieldFloatByName): محتوای فیلد به عنوان عدد اعشاری با نام مشخص از سطر نتیجه فعلی رو دریافت کنید
175+
- [DB_GetMemHandle](DB_GetMemHandle): handle حافظه برای پایگاه داده SQLite که با db_open باز شده رو دریافت کنید
176+
- [DB_GetLegacyDBResult](DB_GetLegacyDBResult): handle حافظه برای کوئری SQLite که با DB_ExecuteQuery اجرا شده رو دریافت کنید
177+
- [DB_GetDatabaseConnectionCount](DB_GetDatabaseConnectionCount): تعداد اتصالات باز پایگاه داده رو برای اهداف دیباگ دریافت کنید
178+
- [DB_GetDatabaseResultSetCount](DB_GetDatabaseResultSetCount): تعداد نتایج باز پایگاه داده رو دریافت کنید
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
title: DB_GetFieldInt
3+
sidebar_label: DB_GetFieldInt
4+
description: محتوای یک فیلد رو به عنوان یک عدد صحیح از DB_ExecuteQuery دریافت کنید.
5+
keywords:
6+
- sqlite
7+
tags: ["sqlite"]
8+
---
9+
10+
## توضیحات
11+
12+
محتوای یک فیلد رو به عنوان یک عدد صحیح از DB_ExecuteQuery دریافت می‌کنه.
13+
14+
| نام | توضیحات |
15+
| --------------- | ---------------------------------- |
16+
| DBResult:result | نتیجه‌ای که داده‌ها از اون گرفته میشه. |
17+
| field = 0 | فیلدی که داده‌ها از اون گرفته میشه. |
18+
19+
## مقدار بازگشتی
20+
21+
مقدار بازیابی شده به عنوان یک عدد صحیح.
22+
23+
## مثال
24+
25+
```c
26+
// examples.inc
27+
28+
// ...
29+
30+
static FindFieldIndexByName(DBResult:dbResultSet, const fieldName[])
31+
{
32+
// Return value variable with default return value
33+
new ret = -1;
34+
35+
// Field count
36+
new field_count = DB_GetFieldCount(dbResultSet);
37+
38+
// Current field name
39+
new current_field_name[32];
40+
41+
// Iterate through all fields
42+
for (new field_index; field_index < field_count; field_index++)
43+
{
44+
// Get field name
45+
if (DB_GetFieldName(dbResultSet, field_index, current_field_name, sizeof current_field_name))
46+
{
47+
// Compare searched field name to current field name
48+
if (!strcmp(fieldName, current_field_name))
49+
{
50+
// Success, store field index to return value variable
51+
ret = field_index;
52+
53+
// Break out of the loop
54+
break;
55+
}
56+
}
57+
}
58+
59+
// Return found field index or "-1"
60+
return ret;
61+
}
62+
63+
Examples_CalculateSum(DB:dbConnectionHandle)
64+
{
65+
// Return value variable
66+
new ret;
67+
68+
// Database result set
69+
new DBResult:db_result_set = DB_ExecuteQuery("SELECT `value` FROM `examples`");
70+
71+
// If database result set is valid
72+
if (db_result_set)
73+
{
74+
// Get target field index
75+
new target_field_index = FindFieldIndexByName(db_result_set, "value");
76+
77+
// Check if field index is valid
78+
if (target_field_index >= 0)
79+
{
80+
// Do operations
81+
do
82+
{
83+
// Add value from "example" field to the return value variable
84+
ret += DB_GetFieldInt(db_result_set, target_field_index);
85+
}
86+
87+
// While next row could be fetched
88+
while (DB_SelectNextRow(db_result_set));
89+
}
90+
91+
// Free result set
92+
DB_FreeResultSet(db_result_set);
93+
}
94+
95+
// Return calculated sum
96+
return ret;
97+
}
98+
```
99+
100+
```c
101+
// mode.pwn
102+
103+
// ...
104+
105+
#include <examples>
106+
107+
static DB:gDBConnectionHandle;
108+
109+
// ...
110+
111+
public OnGameModeInit()
112+
{
113+
// ...
114+
115+
// Create a connection to a database
116+
gDBConnectionHandle = DB_Open("example.db");
117+
118+
// If connection to the database exists
119+
if (gDBConnectionHandle)
120+
{
121+
// Successfully created a connection to the database
122+
print("Successfully created a connection to database \"example.db\".");
123+
printf("Calculated sum: %d", Examples_CalculateSum(gDBConnectionHandle));
124+
}
125+
else
126+
{
127+
// Failed to create a connection to the database
128+
print("Failed to open a connection to database \"example.db\".");
129+
}
130+
131+
// ...
132+
133+
return 1;
134+
}
135+
136+
public OnGameModeExit()
137+
{
138+
// Close the connection to the database if connection is open
139+
if (DB_Close(gDBConnectionHandle))
140+
{
141+
// Extra cleanup
142+
gDBConnectionHandle = DB:0;
143+
}
144+
145+
// ...
146+
147+
return 1;
148+
}
149+
```
150+
151+
## نکات
152+
153+
:::warning
154+
155+
استفاده از یک handle نامعتبر غیر از صفر سرور شما رو کرش می‌کنه! یک handle اتصال پایگاه داده معتبر رو با استفاده از [DB_ExecuteQuery](DB_ExecuteQuery) دریافت کنید.
156+
157+
:::
158+
159+
## توابع مرتبط
160+
161+
- [DB_Open](DB_Open): اتصال به پایگاه داده SQLite باز کنید
162+
- [DB_Close](DB_Close): اتصال به پایگاه داده SQLite بسته کنید
163+
- [DB_ExecuteQuery](DB_ExecuteQuery): پایگاه داده SQLite رو کوئری کنید
164+
- [DB_FreeResultSet](DB_FreeResultSet): حافظه نتیجه رو از DB_ExecuteQuery آزاد کنید
165+
- [DB_GetRowCount](DB_GetRowCount): تعداد سطرهای یک نتیجه رو دریافت کنید
166+
- [DB_SelectNextRow](DB_SelectNextRow): به سطر بعدی بروید
167+
- [DB_GetFieldCount](DB_GetFieldCount): تعداد فیلدهای یک نتیجه رو دریافت کنید
168+
- [DB_GetFieldName](DB_GetFieldName): نام یک فیلد در ایندکس مشخص رو برگردونه
169+
- [DB_GetFieldString](DB_GetFieldString): محتوای فیلد با ID مشخص از سطر نتیجه فعلی رو دریافت کنید
170+
- [DB_GetFieldStringByName](DB_GetFieldStringByName): محتوای فیلد با نام مشخص از سطر نتیجه فعلی رو دریافت کنید
171+
- [DB_GetFieldInt](DB_GetFieldInt): محتوای فیلد به عنوان عدد صحیح با ID مشخص از سطر نتیجه فعلی رو دریافت کنید
172+
- [DB_GetFieldIntByName](DB_GetFieldIntByName): محتوای فیلد به عنوان عدد صحیح با نام مشخص از سطر نتیجه فعلی رو دریافت کنید
173+
- [DB_GetFieldFloat](DB_GetFieldFloat): محتوای فیلد به عنوان عدد اعشاری با ID مشخص از سطر نتیجه فعلی رو دریافت کنید
174+
- [DB_GetFieldFloatByName](DB_GetFieldFloatByName): محتوای فیلد به عنوان عدد اعشاری با نام مشخص از سطر نتیجه فعلی رو دریافت کنید
175+
- [DB_GetMemHandle](DB_GetMemHandle): handle حافظه برای پایگاه داده SQLite که با db_open باز شده رو دریافت کنید
176+
- [DB_GetLegacyDBResult](DB_GetLegacyDBResult): handle حافظه برای کوئری SQLite که با DB_ExecuteQuery اجرا شده رو دریافت کنید
177+
- [DB_GetDatabaseConnectionCount](DB_GetDatabaseConnectionCount): تعداد اتصالات باز پایگاه داده رو برای اهداف دیباگ دریافت کنید
178+
- [DB_GetDatabaseResultSetCount](DB_GetDatabaseResultSetCount): تعداد نتایج باز پایگاه داده رو دریافت کنید

0 commit comments

Comments
 (0)