# Zhamao Framework: DBWrapper类 参考

DBWrapper类 参考

## Public 成员函数

| __construct (string $name)
| __destruct ()
| getDatabase ()
| isAutoCommit ()
| setAutoCommit (bool $auto_commit)
| fetchAssociative (string $query, array $params=[], array $types=[])
| fetchNumeric (string $query, array $params=[], array $types=[])
| fetchOne (string $query, array $params=[], array $types=[])
| isTransactionActive ()
| delete (string $table, array $criteria, array $types=[])
| setTransactionIsolation (int $level)
| getTransactionIsolation ()
| update (string $table, array $data, array $criteria, array $types=[])
| insert (string $table, array $data, array $types=[])
| quoteIdentifier (string $str)
| quote (mixed $value, $type=ParameterType::STRING)
| fetchAllNumeric (string $query, array $params=[], array $types=[])
| fetchAllAssociative (string $query, array $params=[], array $types=[])
| fetchAllKeyValue (string $query, array $params=[], array $types=[])
| fetchAllAssociativeIndexed (string $query, array $params=[], array $types=[])
| fetchFirstColumn (string $query, array $params=[], array $types=[])
| iterateNumeric (string $query, array $params=[], array $types=[])
| iterateAssociative (string $query, array $params=[], array $types=[])
| iterateKeyValue (string $query, array $params=[], array $types=[])
| iterateAssociativeIndexed (string $query, array $params=[], array $types=[])
| iterateColumn (string $query, array $params=[], array $types=[])
| executeQuery (string $sql, array $params=[], array $types=[], ?QueryCacheProfile $qcp=null)
| executeCacheQuery (string $sql, array $params, array $types, QueryCacheProfile $qcp)
| executeStatement (string $sql, array $params=[], array $types=[])
| getTransactionNestingLevel ()
| lastInsertId (?string $name=null)
| transactional (\Closure $func)
| setNestTransactionsWithSavepoints (bool $nest_transactions_with_savepoints)
| getNestTransactionsWithSavepoints ()
| beginTransaction ()
| commit ()
| rollBack ()
| createSavepoint (string $savepoint)
| releaseSavepoint (string $savepoint)
| rollbackSavepoint (string $savepoint)
| setRollbackOnly ()
| isRollbackOnly ()
| createQueryBuilder ()
| getConnection ()

## 构造及析构函数说明

## __construct()

__construct | ( | string | $name | ) |

DBWrapper constructor.

异常

  DBException |

函数调用图:

## __destruct()

__destruct | ( |  | ) |

## 成员函数说明

## beginTransaction()

beginTransaction | ( |  | ) |

wrapper method

## commit()

commit | ( |  | ) |

wrapper method

异常

  DBException |

## createQueryBuilder()

createQueryBuilder | ( |  | ) |

overwrite method to $this->connection->createQueryBuilder

## createSavepoint()

createSavepoint | ( | string | $savepoint | ) |

wrapper method

参数

  string | $savepoint | the name of the savepoint to create

异常

  DBException |

## delete()

delete | ( | string | $table,
|  | array | $criteria,
|  | array | $types = `[]`
| ) |  |

参数

  string | $table | 表

异常

  DBException |

## executeCacheQuery()

executeCacheQuery | ( | string | $sql,
|  | array | $params,
|  | array | $types,
|  | QueryCacheProfile | $qcp
| ) |  |

wrapper method

参数

  string | $sql | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

异常

  DBException |

## executeQuery()

executeQuery | ( | string | $sql,
|  | array | $params = `[]`,
|  | array | $types = `[]`,
|  | ?QueryCacheProfile | $qcp = `null`
| ) |  |

wrapper method

参数

  string | $sql | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

异常

  DBException |

## executeStatement()

executeStatement | ( | string | $sql,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $sql | SQL statement
  | array<int,mixed>|array<string,mixed> | $params Statement parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  int|string the number of affected rows

异常

  DBException |

## fetchAllAssociative()

fetchAllAssociative | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  array<int,array<string,mixed>>

异常

  DBException |

## fetchAllAssociativeIndexed()

fetchAllAssociativeIndexed | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,int|string>|array<string,int|string> | $types Parameter types

返回
  array<mixed,array<string,mixed>>

异常

  DBException |

## fetchAllKeyValue()

fetchAllKeyValue | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,int|string>|array<string,int|string> | $types Parameter types

异常

  DBException |

## fetchAllNumeric()

fetchAllNumeric | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  array<int,array<int,mixed>>

异常

  DBException |

## fetchAssociative()

fetchAssociative | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

异常

  DBException |

## fetchFirstColumn()

fetchFirstColumn | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  array<int,mixed>

异常

  DBException |

## fetchNumeric()

fetchNumeric | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

异常

  DBException |

## fetchOne()

fetchOne | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

返回
  false|mixed

异常

  DBException |

## getConnection()

getConnection | ( |  | ) |

## getDatabase()

getDatabase | ( |  | ) |

wrapper method

## getNestTransactionsWithSavepoints()

getNestTransactionsWithSavepoints | ( |  | ) |

wrapper method

## getTransactionIsolation()

getTransactionIsolation | ( |  | ) |

wrapper method

## getTransactionNestingLevel()

getTransactionNestingLevel | ( |  | ) |

wrapper method

## insert()

insert | ( | string | $table,
|  | array | $data,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $table | 表名

异常

  DBException |

## isAutoCommit()

isAutoCommit | ( |  | ) |

wrapper method

## isRollbackOnly()

isRollbackOnly | ( |  | ) |

wrapper method

异常

  DBException |

## isTransactionActive()

isTransactionActive | ( |  | ) |

wrapper method

## iterateAssociative()

iterateAssociative | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  \Traversable<int,array<string,mixed>>

异常

  DBException |

## iterateAssociativeIndexed()

iterateAssociativeIndexed | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,int|string>|array<string,int|string> | $types Parameter types

返回
  \Traversable<mixed,array<string,mixed>>

异常

  DBException |

## iterateColumn()

iterateColumn | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  \Traversable<int,mixed>

异常

  DBException |

## iterateKeyValue()

iterateKeyValue | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,int|string>|array<string,int|string> | $types Parameter types

返回
  \Traversable<mixed,mixed>

异常

  DBException |

## iterateNumeric()

iterateNumeric | ( | string | $query,
|  | array | $params = `[]`,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $query | SQL query
  | array<int,mixed>|array<string,mixed> | $params Query parameters
  | array<int,null|int|string|Type>|array<string,null|int|string|Type> | $types Parameter types

返回
  \Traversable<int,array<int,mixed>>

异常

  DBException |

## lastInsertId()

lastInsertId | ( | ?string | $name = `null` | ) |

wrapper method

参数

  null | string | $name | name of the sequence object from which the ID should be returned

返回
  false|int|string a string representation of the last inserted ID

## quote()

quote | ( | mixed | $value,
|  |  | $type = `ParameterType::STRING`
| ) |  |

wrapper method

参数

  null | int | string | Type | $type |

## quoteIdentifier()

quoteIdentifier | ( | string | $str | ) |

wrapper method

参数

  string | $str | The name to be quoted

## releaseSavepoint()

releaseSavepoint | ( | string | $savepoint | ) |

wrapper method

参数

  string | $savepoint | the name of the savepoint to release

异常

  DBException |

## rollBack()

rollBack | ( |  | ) |

wrapper method

异常

  DBException |

## rollbackSavepoint()

rollbackSavepoint | ( | string | $savepoint | ) |

wrapper method

参数

  string | $savepoint | the name of the savepoint to rollback to

异常

  DBException |

## setAutoCommit()

setAutoCommit | ( | bool | $auto_commit | ) |

wrapper method

## setNestTransactionsWithSavepoints()

setNestTransactionsWithSavepoints | ( | bool | $nest_transactions_with_savepoints | ) |

wrapper method

异常

  DBException |

## setRollbackOnly()

setRollbackOnly | ( |  | ) |

wrapper method

异常

  DBException |

## setTransactionIsolation()

setTransactionIsolation | ( | int | $level | ) |

wrapper method

参数

  int | $level | Sets the transaction isolation level

## transactional()

transactional | ( | \Closure | $func | ) |

overwrite method to $this->connection->transactional()

返回
  mixed

异常

  DBException |

函数调用图:

## update()

update | ( | string | $table,
|  | array | $data,
|  | array | $criteria,
|  | array | $types = `[]`
| ) |  |

wrapper method

参数

  string | $table | 表名

异常

  DBException |

该类的文档由以下文件生成:

- src/ZM/Store/Database/DBWrapper.php