Data structures that represents values in the database. More...
#include "db_con.h"#include <time.h>#include "../../str.h"#include "db_con.h"

Go to the source code of this file.
Each cell in a database table can be of a different type.
More...This file defines data structures that represents values in the database. Several datatypes are recognized and converted by the database API. Available types: DB1_INT, DB1_DOUBLE, DB1_STRING, DB1_STR, DB1_DATETIME, DB1_BLOB and DB1_BITMAP It also provides some macros for convenient access to this values, and a function to convert a str to a value.
Definition in file db_val.h.
| #define VAL_FREE | ( | dv | ) | ((dv)->free) |
A non-zero flag means that the corresponding cell in the database contains data that must be freed from the DB API.
Definition at line 119 of file db_val.h.
Referenced by bdb_str2val(), db_free_row(), db_postgres_str2val(), and db_str2val().
| #define VAL_NULL | ( | dv | ) | ((dv)->nul) |
A non-zero flag means that the corresponding cell in the database contains no data (a NULL value in MySQL terminology).
Definition at line 111 of file db_val.h.
Referenced by bdb_str2val(), db_free_row(), db_load_urecord_by_ruid(), db_postgres_replace(), db_str2val(), db_table_version(), db_val2str(), dbrow2info(), get_all_db_ucontacts(), is_user_in(), preload_udomain(), and testdb_udomain().
| #define VAL_TYPE | ( | dv | ) | ((dv)->type) |
All macros expect a reference to a db_val_t variable as parameter. Use this macro if you need to set/get the type of the value.
Definition at line 103 of file db_val.h.
Referenced by bdb_str2val(), db_free_row(), db_mysql_val2str(), db_postgres_replace(), db_postgres_str2val(), db_postgres_val2str(), db_str2val(), db_table_version(), db_val2str(), is_user_in(), and testdb_udomain().
| enum db_type_t |
To distinguish among these types, the db_type_t enumeration is used. Every value of the enumeration represents one datatype that is recognized by the database API.
| int db_str2val | ( | const db_type_t | _t, | |
| db_val_t * | _v, | |||
| const char * | _s, | |||
| const int | _l, | |||
| const unsigned int | _cpy | |||
| ) |
Convert a str to a db value, does not copy strings if _cpy is zero
| _t | destination value type | |
| _v | destination value | |
| _s | source string | |
| _l | string length | |
| _cpy | when set to zero does not copy strings, otherwise copy strings |
Convert a str to a db value, copy strings if _cpy is not zero. Copying is not necessary if the result from the database client library is freed after the result inside the server is processed. If the result is freed earlier, e.g. because its saved inside some temporary storage, then it must be copied in order to be use it reliable.
| _t | destination value type | |
| _v | destination value | |
| _s | source string | |
| _l | string length | |
| _cpy | when set to zero does not copy strings, otherwise copy strings |
Definition at line 45 of file db_val.c.
References DB1_BIGINT, DB1_BITMAP, DB1_BLOB, DB1_DATETIME, DB1_DOUBLE, DB1_INT, DB1_STR, DB1_STRING, db_str2double(), db_str2int(), db_str2longlong(), db_str2time(), _str::s, VAL_BIGINT, VAL_BLOB, VAL_DOUBLE, VAL_FREE, VAL_INT, VAL_NULL, VAL_STR, VAL_STRING, VAL_TIME, and VAL_TYPE.

Convert a numerical value to a string, used when converting result from a query. Implement common functionality needed from the databases, does parameter checking.
| _c | database connection | |
| _v | source value | |
| _s | target string | |
| _len | target string length |
Definition at line 202 of file db_val.c.
References DB1_BIGINT, DB1_BITMAP, DB1_DATETIME, DB1_DOUBLE, DB1_INT, db_double2str(), db_int2str(), db_longlong2str(), db_time2str(), VAL_BIGINT, VAL_BITMAP, VAL_DOUBLE, VAL_INT, VAL_NULL, VAL_TIME, and VAL_TYPE.

1.7.1