77
>2.3. DBD Helper Functions</A
77
>2.4. DBD Helper Functions</A
80
>libdbi implements a couple of functions which come in handy when implementing database engine drivers. Call them from your driver code if appropriate.</P
84
86
NAME="INTERNAL-DBD-RESULT-CREATE"
85
>2.3.1. _dbd_result_create</A
87
>2.4.1. _dbd_result_create</A
97
CLASS="PROGRAMLISTING"
98
>dbi_result_t *_dbd_result_create(dbi_conn_t *conn, void *handle, unsigned int numrows_matched, unsigned int numrows_affected)</PRE
102
>_dbd_result_create</B
110
>, unsigned long long <VAR
112
>numrows_matched</VAR
113
>, unsigned long long <VAR
115
>numrows_affected</VAR
105
122
>Allocates a new dbi_result_t, filling the number of rows matched and affected, storing the database-specific result handle, and allocating room for rows to be stored.</P
405
465
CLASS="VARIABLELIST"
416
474
>: The target connection.</P
421
479
>: The error message to store. This will be stdup'd by libdbi so it has its own copy.</P
426
484
>: The error number to store.</P
494
NAME="INTERNAL-DBD-RESULT-CREATE-FROM-STRINGARRAY"
495
>2.4.7. _dbd_result_create_from_stringarray</A
510
>_dbd_result_create_from_stringarray</B
515
>, unsigned long long <VAR
517
>numrows_matched</VAR
527
>Creates a result object from an array of strings which contains the data of a single field for each row.</P
540
>: The target connection.</P
545
>: The number of rows contained in the <CODE
553
>: A pointer to an array of strings with <CODE
555
>numrows_matched</CODE
564
>A result object, or NULL if there is an error.</P
574
NAME="INTERNAL-DBD-REGISTER-DRIVER-CAP"
575
>2.4.8. _dbd_register_driver_cap</A
590
>_dbd_register_driver_cap</B
607
>Adds a key-value pair to the list of driver capabilities.</P
620
>: The target driver.</P
640
NAME="INTERNAL-DBD-REGISTER-CONN-CAP"
641
>2.4.9. _dbd_register_conn_cap</A
656
>_dbd_register_conn_cap</B
673
>Adds a key-value pair to the list of connection capabilities.</P
686
>: The target connection.</P
706
NAME="INTERNAL-DBD-PARSE-DATETIME"
707
>2.4.10. _dbd_parse_datetime</A
722
>_dbd_parse_datetime</B
736
>Parses the input time, date, or datetime string and converts the value into a time_t value.</P
749
>: A zero-terminated string containing a time, date, or datetime value. Accepted formats are YYYY-MM-DD for date values, HH:MM:SS for time values, and YYYY-MM-DD HH:MM:SS for datetime values. The separators must be present, but can be any character.</P
754
>: The field attributes of raw.</P
762
>The numeric equivalent of the input based on UTC. In case of an error, this function returns the start of the Unix epoch.</P
772
NAME="INTERNAL-DBD-ESCAPE-CHARS"
773
>2.4.11. _dbd_escape_chars</A
788
>_dbd_escape_chars</B
808
>Escapes the characters contained in <CODE
811
> in the string <CODE
814
> and puts the result into the allocated memory pointed to by <CODE
820
> must be at least (<CODE
823
>*2)+5. The characters are escaped by preceding them with a backslash.</P
836
>: Pointer to allocated memory which will receive the escaped string.</P
841
>: The string to escape.</P
846
>: The length of the string to escape.</P
851
>: A string containing all characters that need escaping.</P
859
>The length, in bytes, of the escaped string.</P
869
NAME="INTERNAL-DBD-ENCODE-BINARY"
870
>2.4.12. _dbd_encode_binary</A
885
>_dbd_encode_binary</B
887
>(const unsigned char *<VAR
893
>, unsigned char *<VAR
902
>Encodes a binary string as a zero-terminated string which can be safely included in a SQL query. Use <A
903
HREF="helperfuncs.html#INTERNAL-DBD-DECODE-BINARY"
904
>_dbd_decode_binary</A
905
> to decode the string again.</P
918
>: Pointer to the binary string.</P
923
>: Length, in bytes, of the binary string <CODE
931
>: Pointer to allocated memory which will receive the escaped string. The size must be at least 2 +(257*<CODE
942
>The length, in bytes, of the escaped string.</P
952
NAME="INTERNAL-DBD-DECODE-BINARY"
953
>2.4.13. _dbd_decode_binary</A
968
>_dbd_decode_binary</B
970
>(const unsigned char *<VAR
973
>, unsigned char *<VAR
982
>Decodes a zero-terminated string with escaped characters as created by <A
983
HREF="helperfuncs.html#INTERNAL-DBD-ENCODE-BINARY"
984
>_dbd_encode_binary</A
998
>: Pointer to the input string.</P
1003
>: Pointer to allocated memory which will receive the unescaped string. The output string is always shorter than the input string, i.e. if the size of <CODE
1006
> is the same as the size of <CODE
1009
>, you're on the safe side. The implementation allows to decode the string in place, i.e. <CODE
1012
> may be the same as <CODE
1023
>The length, in bytes, of the unescaped binary string.</P
433
1030
CLASS="NAVFOOTER"