<<

. 125
( 132 .)



>>

by PHP.

MD5(string)
RETURNS: string


LAST_INSERT_ID
This function returns the last automatically generated value that was inserted into
an AUTO_INCREMENT column:

LAST_INSERT_ID()
RETURNS: int


GET_LOCK
This function tries to obtain a lock with a name given by the string str, with a time-
out of timeout seconds. It returns 1 if the lock was obtained successfully, 0 if the
attempt timed out, and NULL if an error occurred (such as running out of memory or
Appendix J: MySQL Function Reference 733

the thread being killed with mysqladmin kill). A lock is released, RELEASE_LOCK()
is executed, a new GET_LOCK() is executed, or the thread terminates.

GET_LOCK(str,timeout)
RETURNS: int


RELEASE_LOCK
This function releases the lock named by the string str that was obtained with
GET_LOCK(). It returns 1 if the lock was released, 0 if the lock wasn™t locked by this
thread (in which case the lock is not released), and NULL if the named lock didn™t
exist.

RELEASE_LOCK(str)
RETURNS: int




Functions for Use with
GROUP BY Clauses
Most of the functions used with the GROUP BY clause were covered in Chapter 3.
There are three additional functions that we did not cover there.

STD/STDDEV
This function returns the standard deviation of expr. It is an extension of ANSI
SQL. The STDDEV() form of this function is provided for Oracle compatibility.

STD(expr)

or

STDDEV(expr)
RETURNS: float


BIT_OR
This function returns the bitwise OR of all bits in expr. The calculation is performed
with 64-bit (BIGINT) precision.

BIT_OR(expr)
RETURNS: int
734 Part V: Appendixes


BIT_AND
This function returns the bitwise AND of all bits in expr. The calculation is per-
formed with 64-bit (BIGINT) precision.

BIT_AND(expr)
RETURNS: int
Index
Symbols arc cosine (ACOS), 706
arc sine (ASIN), 706
$ (dollar sign), 91
arc tangent (ATAN), 706
“ (double quotes), 94
arc tangent of two arguments (ATAN2), 707
= (equals sign), 92
argument
# (space character), 717
arc tangent of two (ATAN2), 707
=== (triple equals sign), 93
concatenation of (CONCAT), 711“712
handling, HTML survey functions, 276“281
A PHP functions, 134“135
absolute pathname, returning (REALPATH()), 175
printing (PRINT_INPUT_FIELDS()), 249“250
absolute value, 702
replacing (STR_REPLACE()), 140
abstract classes, 212“215
script control functions, obtaining
access key, 568
information (func_get_arg(),
action, object. See method
func_get_args(), and
active projects, showing, 544“545
func_num_args()), 176“177
active threads, viewing, 589“590
string, outputting and then terminating
adding
script (die()), 176
to beginning of array (ARRAY_UNSHIFT()),
value in first is found in second
160
(IN_ARRAY()), 159
column to table, 42
variable number, 205“206
to end of array (ARRAY_PUSH()), 160
array
files automatically, 581“582
adding to beginning (ARRAY_UNSHIFT()),
index to table, 43
160
survey questions (admin/questions.php),
assigning, PHP scripts, 96“99
298“303
associative, 162, 671
user to project, 545
browser-passed variables, 102“104
address book, 4
common elements (ARRAY_INTERSECT()), 159
address, file or Web page. See URL
concatenating in a string (JOIN()), 154
Address table, manipulating, 490“491
converting into variables (COMPACT()), 153
administrative tasks, 389“392, 586“587
counting (ARRAY_COUNT()), 157“158
alias (as), 76
creating and populating (RANGE()), 154
alphabetical order
cursor, resetting (RESET()), 162
array (SORT()), 163
described, 615“619
list of entries in table, 73
differences (ARRAY_DIFF()), 159
anchor tag, 671
end, adding to (ARRAY_PUSH()), 160
AND, bitwise (BIT_AND), 734
filtering (ARRAY_FILTER()), 157“158
anomalies, 5, 8, 10
first element, return and remove
anonymous users, 257
(ARRAY_SHIFT()), 160
Apache, 109“111, 696
key
application design
returning all (ARRAY_KEYS()), 158
Guestbook 2003, 229“230
true/false whether exists
NuSOAP, 527“528
(ARRAY_KEY_EXISTS()), 158
problem-tracking system, 441“444
key/value pair
project management, 537“541
exchanging (ARRAY_FLIP()), 155“156
shopping cart, 477“479
pulling and making into standalone
survey, 261“266, 294“298
735
variables (EXTRACT()), 153“154
threaded discussion, 312“315
continued
XML parsing, 506“508
736 Index

array continued atomic value, 11
returning (EACH()), 161 authentication
seeking (ARRAY_KEY_EXISTS()), 159“160 project management code, 546“548
last element, return and remove user for content-management system
(ARRAY_POP()), 160 (content/authenticate.php), 387“389
of matched subpatterns, assigning user-defined functions, 669“670
(PREG_MATCH()), 147 author
matching (PREG_GREP()), 147 creating or updating records
merging or concatenating (write_author()), 381“382
(ARRAY_MERGE()), 156 finding all stories by (function
passing through function (ARRAY_WALK()), fetch_author()), 378
161 average (avg()), group by and aggregate
Perl regular expression string, transforming functions, 78“79
into (PREG_SPLIT()), 152“153
B
of properties (get_object_vars()), 164
random elements, picking (ARRAY_RAND()), Babelfish application, 532“534
162“163 Barnes & Noble application, 528“531
randomizing elements (SHUFFLE()), 163 base
regular expression string, transforming into numbers, converting (CONV), 710
(SPLIT()), 151“152 path elements, cutting off all but
removing specific elements (BASENAME()), 175
(ARRAY_SPLICE()), 156“157 base-10 logarithm (LOG10), 705
return values generated by called function, BC math function, 640
in original order (ARRAY_MAP()), BEGIN(), catalog classes, 422
158“159 beginning of array, adding to
returning values defined in enum field (ARRAY_UNSHIFT()), 160
(enum_to_array()), 679“680 BerkeleyDB, 40“41
sorting in ascending or alphabetical BINARY cast operator, 700
order, 163 binary installation, 572“575
string, transforming (EXPLODE()), 150“151 binary objects (tinytext/tinyblob,
testing (is_array()), 113 text/blob, mediumtext/mediumblob,
turning into string (IMPLODE()), 151 longtext), 31“32
two-dimensional arrays, assigning, 99 binary value, string functions, returning
type other than, testing (is_scalar()), 114 (BIN), 710
user-defined function, passing bitmask, constant, defining to use
(call_user_func_array()), 176 (get_constant()), 345“347
value in first argument is found in second bitwise operators, 733“734
argument (IN_ARRAY()), 159 blocking. See security
values, returning all (ARRAY_VALUES()), 161 body, SOAP (Simple Object Access Protocol),
variable functions, testing (is_array(), 521“522
is_numeric(), and is_string()), 148 Boolean, testing for (is_bool()), 113“114
ascending order, array, sorting (SORT()), 163 border
ASCII HTML form text surrounded by thin line
integers, values of (CHAR), 711 (fieldset), 569
string function values, 709 page, 201
string, specially-formatted (ORD), 709 break, HTML adding after each newline
associative array (NL2BR()), 141“142
database (db_values_array()), 671 break loop, 131, 132
defined, 97“98 browser
values, returning (ARRAY_COUNT_VALUES()), arrays, 102“104
162 HTML forms, 100“102
Index 737

HTTP header, 179“180 new record, creating (CREATE_RECORD()), 419
information stored by, 104“106, 180 object-oriented approach, 408, 410“411
sessions, 106“107 products, 422“431
username and password, getting property values, setting (BUILD()), 414
(authenticate()), 669 query for later-named table
buffering, PHP output, 187“189 (FETCH_SIMPLE_QUERY()), 415
bulleted list (ul_list()), 672 sample script, 434“439
bytes, file pointer reading to specified scope and goals, determining, 398“403
(FREAD()), 172 single record, returning (FETCH_RECORD()),
416
C static variables, using in methods (DBH()),
413“414
calculating. See also mathematical functions
style, 433“434
MD5 checksum, 732
table name, returning result
valid dates (MKTIME()), 168“169
(FETCH_SIMPLE()), 415“416
called function, return values, generated in
updating record (UPDATE_RECORD()), 419
original order (ARRAY_MAP()), 158“159
uploading files, 409“410
capitalization, changing
values, saving them (WRITE_TO_DB()), 420
characters, (LCASE), 718
categories, shopping cart, 492“493
functions (UCASE), 719
CD, back-of-the-book
string (STRTOLOWER(), STRTOUPPER(),
applications, 558“559
UCFIRST(), and UCWORDS()), 141
eBook version of text, 560
case-insensitivity
example applications, 558
pattern match (split()), 155
system requirements, 557
regular expression functions, altering
troubleshooting, 560
(sql_regcase()), 145“146
using, 558
cast operator, BINARY, 700
cell tag, 673
casting, variable types, changing, 114“115
certificates, security, 481“482
catalog
changes, recording most recent (timestamp),
classes
date and time columns, 36
base, 412“413, 431“432
character

<<

. 125
( 132 .)



>>