[ Pobierz całość w formacie PDF ] .FROM_UNIXTIME(unix_timestamp) (used in examples)RETURNS: stringFrom_UnixtimeThis function returns a string representation of the Unix timestamp, formattedaccording to the format string.format may contain the same specifiers as thoselisted in the entry for the DATE_FORMAT() function.FROM_UNIXTIME(unix_timestamp,format) (used in examples)RETURNS: stringSEC_TO_TIMESEC_TO_TIME(seconds)RETURNS: stringReturns the seconds argument, converted to hours, minutes and seconds, as avalue in HH:MM:SS or HHMMSS format, depending on whether the function isused in a string or numeric context.TIME_TO_SECTIME_TO_SEC(time) (used in examples)RETURNS: intThis function returns the time argument, converted to seconds.Miscellaneous FunctionsHere are a few other functions that don t fit under any of the previous categories.DatabaseThis function returns the current database name.If there is no current database,DATABASE() returns the empty string.DATABASE()RETURNS: string3537-4 AppI.f.qc 12/15/00 15:27 Page 581Appendix I: MySQL Function Reference 581UserThis function returns the current MySQL username.In MySQL 3.22.11 or later, thisincludes the client hostname as well as the username.USER()orSYSTEM_USER()orSESSION_USER() (used in examples)RETURNS: stringVERSIONThis function returns a string indicating the MySQL server version.VERSION()RETURNS: stringPASSWORDThis function calculates a password string from the plaintext password str.PASSWORD(str) (used in examples)RETURNS: stringThis is the function that encrypts MySQL passwords for storage in the Passwordcolumn of the user grant table.PASSWORD() encryption is one-way.PASSWORD()does not perform password encryption in the same way that Unix passwords areencrypted.You should not assume that if your Unix password and your MySQLpassword are the same, PASSWORD() will result in the same encrypted value as isstored in the Unix password file.See ENCRYPT().ENCRYPTThis function encrypts str using the Unix crypt() system call.ENCRYPT(str[,salt])RETURNS: stringThe salt argument should be a string with two characters.(As of MySQL3.22.16, salt may be longer than two characters.) If crypt() is not available onyour system, ENCRYPT() always returns NULL.ENCRYPT() ignores all but the firsteight characters of str on most systems.3537-4 AppI.f.qc 12/15/00 15:27 Page 582582 Part V: AppendixesENCODEThis function encrypts str using pass_str as the password.ENCODE(str,pass_str)RETURNS: binary stringTo decrypt the result, use DECODE().The result is a binary string.If you want tosave it in a column, use a BLOB column type.DECODEThis function decrypts the encrypted string crypt_str using pass_str as the pass-word.crypt_str should be a string returned from ENCODE().DECODE(crypt_str,pass_str)RETURNS: stringMD5This function calculates an MD5 checksum for the string.The value is returned asa32-character alpha-numeric string.This is the same as the md5() functions usedby PHP.MD5(string)RETURNS: stringLAST_INSERT_IDThis function returns the last automatically generated value that was inserted intoan AUTO_INCREMENT column.LAST_INSERT_ID()RETURNS: intGET_LOCKThis function tries to obtain a lock with a name given by the string str, with atimeout of timeout seconds.Returns 1 if the lock was obtained successfully, 0 ifthe attempt timed out, or NULL if an error occurred (such as running out of memoryor the thread being killed with mysqladmin kill).A lock is released RELEASE_LOCK() is executed, a new GET_LOCK()a new GET_LOCK() is executed, or the threadterminates.GET_LOCK(str,timeout)RETURNS: int3537-4 AppI.f.qc 12/15/00 15:27 Page 583Appendix I: MySQL Function Reference 583RELEASE_LOCKThis function releases the lock named by the string str that was obtained withGET_LOCK().It returns 1 if the lock was released, 0 if the lock wasn t locked by thisthread (in which case the lock is not released) and NULL if the named lock didn texist.RELEASE_LOCK(str)RETURNS: intFunctions for Use with GROUPBY ClausesMost of the functions that are used with the GROUP BY clase were covered inChapter 3.There are two additional functions which we did not cover there.STD/STDDEVThis function returns the standard deviation of expr.It is an extension of ANSISQL.The STDDEV() form of this function is provided for Oracle compatibility.STD(expr)orSTDDEV(expr)RETURNS: floatBIT_ORThis function returns the bitwise OR of all bits in expr.The calculation is performedwith 64-bit (BIGINT) precision.BIT_OR(expr)RETURNS: intBIT_ANDThis function returns the bitwise AND of all bits in expr.The calculation is performedwith 64-bit (BIGINT) precision.BIT_AND(expr)RETURNS: int3537-4 AppI.f.qc 12/15/00 15:27 Page 5843537-4 AppJ.f.qc 12/15/00 15:27 Page 585Appendix JWhat s on the CD-ROMTO GET THE APPLICATIONS Sections III and IV working you first need to installApache, PHP, and MySQL.You can find these applications on this book s CD-ROMin the /apache, /php, and /mysql directories.Each has subdirectories for Windowsand Unix.Use whichever is appropriate.Then follow the instructions in AppendixB to install these applications.Once Apache, PHP, and MySQL are installed, you will need to copy the PHPscripts that load the databases and run the applications.Copy the entire /bookdirectory from the CD, with all of its subfolders, to the htdocs/ directory of yourApache installation.The files that install the databases are kept in the book/install/ directory.IfApache is running on your system, all you will need to do to install the databasesis open the correct URL in your browser: http://yourdomain/book/install/index.php.(If Apache is on your local machine, the acutal URL will likely behttp://localhost/book/install/index.php).Follow the instructions to install the databases you wish to use.Note that for theinstall script, you will need to enter a valid hostname, username, and password inthe mysql_connect() function on the fourth line of the install/index.php file.Youcan then access all of the applications by moving to http://yourdomain/book/index.html/You should then open the book/functions/db.php file.In the first function,change the $user, $password, and $server arguments to reflect strings that arevalid for your MySQL installation.Also on the CD, you will find the following:A PDF version of this book.Adobe Acrobat Reader 4.PHPmyadmin This excellent utility gives MySQL a graphical user inter-face via a Web browser using PHP scripts.Manual Lemos Form Creation and Validation Class This is a very com-plete set of scripts for creating forms and validating form input.Manual Lemos Database Abstraction Layer This can be helpful if youneed to access more than one database from your PHP scripts.5853537-4 AppJ.f.qc 12/15/00 15:27 Page 586586 Part V: AppendixesPHP Base Library A set of scripts useful for user authentication andother common processes.Scripts from Appendix G.PBMPlus This utility for manipulating images is used in Chapter 10.It will only work on Unix systems.All files with.php extensions can simply be copied to the Web server directoryand will execute when the page is accessed.Files with.tar.gz extensions are intended for Unix systems and must be uncom-pressed before you will be able to use them.Use the following commands:gunzip filename.tar.gztar xf filename
[ Pobierz całość w formacie PDF ]
zanotowane.pldoc.pisz.plpdf.pisz.plhanula1950.keep.pl
|