深圳全飞鸿

标题: adodb函数列表 [打印本页]

作者: zhgc    时间: 2019-9-5 22:37
标题: adodb函数列表
Reference Manual

Variables  变量
$ADODB_COUNTRECS
In database drivers that do not support native recordset counting, controls whether to emulate the functionality
$ADODB_ANSI_PADDING_OFF
Determines whether to right trim CHAR fields
$ADODB_CACHE_DIR
If using recordset caching, determines the directory holding the cached data
$ADODB_CACHE_CLASS
If using recordset caching, specifies a class for cached recordset handling
$ADODB_DATE_LOCALE
Sets a default date and time format for the ADOdb date/time library
$ADODB_FORCE_TYPE
Changes the behavior of empty and null field handling when updating or creating records
$ADODB_FETCH_MODE
Sets the global array type (numeric or associative) for returned recordsets
$ADODB_GETONE_EOF
Sets the returned value if a valid SQL statement does not match any record when the method getOne() is executed.
$ADODB_LANG
Sets the language for error messages
$ADODB_QUOTE_FIELDNAMES
Quotes, and optionally controls the casing of field name in constructed SQL statements




Constants 常量
ADODB_ASSOC_CASEControls the case-specifity of recordset keys returned as associative arrays
ADODB_DEFAULT_METATYPEControls the default value returned if an unknown data type is tested
The Database Connection Object 数据库连接对象

Establishing Connections 建立连接
adoNewConnection()
Create a new connection object
connect()
Establishes a non-persistent connection with a database
isConnected()
Indicates if a connection has been established
newAdoConnection()
Is a pseudonym for adoNewConnection()
nConnect()
Forces the establishment of  a new connection with a database
pConnect()
Establishes a persistent connection with a database
selectDb()
Select which database to connect to
setconnectionparameter()
Sets an optional connection parameter
close()
Closes a database connection




Working With Cached RecordsetsADOdb supports the ability to work with cached query results, either through storing the results on local disks, or via the use of a Memcached Server. The functions below work the same as their non-caching equivalents, but also check for the availabiltiy of cached results first. This can help reduce database load.
Local Caching Setup
Configuring local parameters for caching
Memcached Setup
Configuring a memcached server connection
cacheExecute()
Executes a provided SQL statement and returns a handle to the result, or a cached handle if available
cacheGetAll()
Executes a provided SQL statement and returns the entire recordset into an array
cacheGetAssoc()
Executes a provided SQL statement and returns the entire recordset into an associatitive array with the value of the first column as a key
cacheGetCol()
Executes a provided SQL statement and returns the first column of each row in the  recordset into an array
cacheGetOne()
Retrieves the first column of the first matching row of an executed SQL statement
cacheGetRow()
Retrieves the first matching row of an executed SQL statement
cacheSelectLimit()
Executes a provided SQL statement and returns a handle to the result, with the ability to supply a starting offset and record count
cacheFlush()
Flushes a cached result set




Executing SQL 执行语句
autoExecute()
Automatically prepares and executes Insert and Update statements based on supplied parameters
execute()
Executes a provided SQL statement and returns a handle to the result
getAll()
Executes a provided SQL statement and returns the entire recordset into an array
getAssoc()
Executes a provided SQL statement and returns the entire recordset into an associatitive array with the value of the first column as a key
getCol()
Executes a provided SQL statement and returns the first column of each row of he entire recordset into an array
getMedian()
Returns the median value of a column in a table
getOne()
Retrieves the first column of the first matching row of an executed SQL statement
getRow()
Retrieves the first matching row of an executed SQL statement
replace()
Provides a simple single record replacement function
selectlimit()
Executes a provided SQL statement and returns a handle to the result, with the ability to supply a starting offset and record count
setCharSet()
Sets the character set for database connections (limited databases)




Prepared Statements
inParameter()
Sets an input parameter to a stored procedure
outParameter()
Receives an output parameter from a stored procedure
param()
Returns a database specific parameter placeholder
prepare()
Prepares an SQL statement and returns a handle to use
prepareSp()
Access a stored procedure and returns a handle to the procedure




Generating Database Independent SQL strings
addQ()
Quotes a string, without prefixing nor appending quotes
charMax()
Returns the largest length of data that can be inserted into a character field
concat()
Returns a database-specific concatenation of strings
getUpdateSQL()
Creates a database-specific SQL UPDATE statement based on supplied parameters
getInsertSQL()
Creates a database-specific SQL INSERT statement based on supplied parameters
ifNull()
Replaces a null value with a specified replacement
quote()
Is a pseudonym for the function qstr
qStr()
Appropriately quotes strings with ' characters for insertion into the database
textMax()
Returns the largest length of data that can be inserted into a text field




Handling Blobs
blobDecode()
Decodes an encoded blob
blobEncode()
Encodes a blob field in preparation for database insertion
updateBlob()
Updates a blob field in a table using a syntax similar to autoexecute
updateBlobFile()
Updates a blob field in a table directly from a disk file using a syntax similar to autoexecute
updateClob()
Updates a clob field in a table using a syntax similar to autoexecute




Paging/Scrolling  分页
absolutePage()
gets or sets the current page number in a paged recordset
atFirstPage()
gets or sets whether at the first page in a paged recordset
atLastPage()
gets or sets whether at the last page in a paged recordset
cachePageExecute()
Return a requested page from a (possibly) cached recordset
lastPageNo()
Returns the page number of the last page in a paged recordset
maxRecordCount()
Returns the maximum number of records that can be returned when paging
pageExecute()
Returns a requested page from a recordset




Transaction Scoping 事务
beginTrans()
Begins a granular transaction
commitTrans()
Commits a granular transaction
completeTrans()
Completes a smart transaction
failTrans()
Forces a smart transaction to fail
hasFailedTrans()
Reports if a granular transaction has failed
rollbackTrans()
Rollback a smart transaction
setTransactionMode()
Sets the isolation level of a transaction.
startTrans()
Starts a smart transaction
transCnt Returns the nesting level of smart transactions
transOffTemporarily disables transactions




Fetching Data
getFetchMode()Get the array type for return data
setFetchMode()Set the array type for return data




Manipulating Dates & Times
bindDate()
Creates a portable date field, for use in bind statements
bindTimeStamp()
Creates a portable timestamp field, for use in bind statements
dbDate()
Creates a portable date field, for use in SQL statements
dbTimeStamp()
Creates a portable timestamp field, for use in SQL statements
offsetDate()
Creates a portable date offset field, for use in SQL statements
setDateLocale()
Changes the SQL connection to a specified Locale
sqlDate()
Returns a portably-formatted date string from a timestamp database column
unixDate()
Uses the database connection to create date strings
unixTimeStamp()
Uses the database connection to create date/time strings




Row Management
affected_rows()Returns the number of rows affected by the last operation
createSequence()Creates a sequence in the database
dropSequence()Drops a sequence in the database
genId()A portable method of creating sequence numbers
insert_id()Returns the last auto-increment number for an SQL statement
rowLock()Lock a table row for a duration of a transaction




Error Handling
errorMsg()Returns a database specific error message
ignoreErrors()Overrides the built-in transaction and error handling status
metaError()Returns a portable error number based on a database specific error
metaErrorMsg()Returns a portable error message based on a portable error number. The language of the message may be controlled by $ADODB_LANG




Query Rewriting
fnExecute and fnCacheExecute
A reference to a function that overrides the execute function




The Recordset Object


Returns one field
fields()Returns a single field in a single row of the current recordset




PEAR CompatibilityThis series of  functions is designed to duplicate the commands and emulate the functionality provided by the now deprecated PEAR DB module. ADOdb also provides an unsupported PEAR Auth connection plugin in the /adodb/pear/auth directory.
fetchInto()
Fetches  a recordset into an array
fetchNextObj()
Returns the current row as an object for convenience and advances the record pointer
fetchNextObject
This is a pseudonym for fetchNextObj
fetchObj()
Returns the current row as an object for convenience
fetchObject()
This is a pseudonym for fetchObj
fetchRow()
Reads  a row of a result set and advances the recordset pointer
free()
Is a pseudonym for close()
getRowAssoc()
Reads a row in associative mode if the recordset fetch mode is numeric
numCols()
Returns the number of columns in a row of a returned recordset
numRows()
Returns the number of rows in a returned recordset




Returns all rows
getArray()Returns a complete recordset as an array
getAssoc()Returns an associate key/value array, with other options
getRows()This function is a pseudonym for getArray(), for ADO compatibility
getRandRow()Returns a random record from a recordset




Scrolling
move()
Move to the nth record of a recordset
moveNext()
Moves the cursor to the next record of the recordset from the current position
moveFirst()
Moves the cursor to the first record of the recordset
moveLast()
Moves to the last record of a recordset
AbsolutePosition()
absolutePosition() is a pseudonym for currentRow()
currentRow()
Returns the current row number of a recordset




Menu generation
getMenu()
Creates a string containing a basic HTML select box
getMenu2()
Creates a string containing a basic HTML select box with alternate comparison criteria to getMenu()
getMenu3()
Creates a string containing a grouped HTML muilti-select box




Dates
unixDate()
Uses the DBMS to return a timestamp from a date string
unixTimeStamp()
Uses the DBMS to return a timestamp from a date/time string
userDate()
Returns a formatted date string for a user supplied timestamp
userTimeStamp()
Returns a formatted date/time string for a user supplied timestamp




Recordset Info
nextRecordSet()
In databases that allow accessing of recordsets, retrieves the next set
po_recordCount() A Portable record count supported by all databases
recordCount() Interface to the native driver recordCount function
rowCount()Is a synonym for recordCount()



Field Info
fetchField()
Returns raw, database specific information about a field
fieldCount()
Returns the the number of fields in a row of a recordset
fieldTypesArray()
Returns an array of all the ADOFieldObjects columns in a row




Recordset Cleanup
close()Closes both the recordset and database connection









作者: zhgc    时间: 2020-3-21 21:14
define(‘ADODB_FETCH_DEFAULT’,0);
define(‘ADODB_FETCH_NUM’,1);
define(‘ADODB_FETCH_ASSOC’,2);
define(‘ADODB_FETCH_BOTH’,3);
作者: zhgc    时间: 2020-3-22 19:29
  1.         include_once 'conn/conn.php';                                                        //载入数据库链接文件
  2.         $conn -> BeginTrans();                                                                //开始事务处理
  3.         $sql = 'delete from tb_object where id = 3';                                //sql删除语句
  4.         $rst = $conn -> execute($sql) or die('execute error:  '.$conn -> ErrorMsg());                 //执行删除语句
  5.         $num = $conn -> Affected_rows();                                                //查看被更新的记录数
  6.         if(false !== $rst){                                                                        //如果$rst不为假
  7.                 if($num != 0){                                                                        //如果$num不为0,说明删除成功
  8.                         $conn -> CommitTrans();                                                //执行提交
  9.                         echo '删除成功!';
  10.                         exit();
  11.                 }else{                                                                                //如果$num为0,说明没有删除记录
  12.                         echo '没有数据,或数据已删除';
  13.                         exit();
  14.                 }
  15.         }else{                                                                                        //如果发生意外
  16.                 $conn -> RollbackTrans();                                                //执行回滚操作
  17.                 echo '出现意外。';
复制代码





欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2