本文整理汇总了PHP中Nette\Database\Connection::getSupplementalDriver方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getSupplementalDriver方法的具体用法?PHP Connection::getSupplementalDriver怎么用?PHP Connection::getSupplementalDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Connection
的用法示例。
在下文中一共展示了Connection::getSupplementalDriver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalizeRow
/**
* Normalizes result row.
* @param array
* @return array
*/
public function normalizeRow($row)
{
if ($this->types === NULL) {
$this->types = array();
if ($this->connection->getSupplementalDriver()->supports['meta']) {
// workaround for PHP bugs #53782, #54695
$col = 0;
foreach ($row as $key => $foo) {
$type = $this->getColumnMeta($col++);
if (isset($type['native_type'])) {
$this->types[$key] = Reflection\DatabaseReflection::detectType($type['native_type']);
}
}
}
}
foreach ($this->types as $key => $type) {
$value = $row[$key];
if ($value === NULL || $value === FALSE || $type === Reflection\DatabaseReflection::FIELD_TEXT) {
} elseif ($type === Reflection\DatabaseReflection::FIELD_INTEGER) {
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
} elseif ($type === Reflection\DatabaseReflection::FIELD_FLOAT) {
$row[$key] = (string) ($tmp = (double) $value) === $value ? $tmp : $value;
} elseif ($type === Reflection\DatabaseReflection::FIELD_BOOL) {
$row[$key] = (bool) $value && $value !== 'f' && $value !== 'F';
}
}
return $this->connection->getSupplementalDriver()->normalizeRow($row, $this);
}
示例2: __construct
public function __construct(Connection $connection, $queryString, array $params)
{
$time = microtime(TRUE);
$this->connection = $connection;
$this->supplementalDriver = $connection->getSupplementalDriver();
$this->queryString = $queryString;
$this->params = $params;
try {
if (substr($queryString, 0, 2) === '::') {
$connection->getPdo()->{substr($queryString, 2)}();
} elseif ($queryString !== NULL) {
static $types = ['boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT, 'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL];
$this->pdoStatement = $connection->getPdo()->prepare($queryString);
foreach ($params as $key => $value) {
$type = gettype($value);
$this->pdoStatement->bindValue(is_int($key) ? $key + 1 : $key, $value, isset($types[$type]) ? $types[$type] : PDO::PARAM_STR);
}
$this->pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
$this->pdoStatement->execute();
}
} catch (\PDOException $e) {
$e = $this->supplementalDriver->convertException($e);
$e->queryString = $queryString;
throw $e;
}
$this->time = microtime(TRUE) - $time;
}
示例3: __construct
public function __construct($tableName, Connection $connection, IReflection $reflection)
{
$this->tableName = $tableName;
$this->databaseReflection = $reflection;
$this->driver = $connection->getSupplementalDriver();
$this->delimitedTable = implode('.', array_map(array($this->driver, 'delimite'), explode('.', $tableName)));
}
示例4: normalizeRow
/**
* Normalizes result row.
* @param array
* @return array
*/
public function normalizeRow($row)
{
if ($this->types === NULL) {
try {
$this->types = array();
foreach ($row as $key => $foo) {
$type = $this->getColumnMeta(count($this->types));
if (isset($type['native_type'])) {
$this->types[$key] = DatabaseReflection::detectType($type['native_type']);
}
}
} catch (\PDOException $e) {
}
}
foreach ($this->types as $key => $type) {
$value = $row[$key];
if ($value === NULL || $value === FALSE || $type === DatabaseReflection::FIELD_TEXT) {
} elseif ($type === DatabaseReflection::FIELD_INTEGER) {
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
} elseif ($type === DatabaseReflection::FIELD_FLOAT) {
$row[$key] = (string) ($tmp = (float) $value) === $value ? $tmp : $value;
} elseif ($type === DatabaseReflection::FIELD_BOOL) {
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
}
}
return $this->connection->getSupplementalDriver()->normalizeRow($row, $this);
}
示例5: tryDelimite
protected function tryDelimite($s)
{
$driver = $this->connection->getSupplementalDriver();
return preg_replace_callback('#(?<=[\\s,<>=]|^)[a-z_][a-z0-9_.]*(?=[\\s,<>=]|$)#i', function ($m) use($driver) {
return strtoupper($m[0]) === $m[0] ? $m[0] : implode('.', array_map(array($driver, 'delimite'), explode('.', $m[0])));
}, $s);
}
示例6: tryDelimite
protected function tryDelimite($s)
{
$driver = $this->connection->getSupplementalDriver();
return preg_replace_callback('#(?<=[^\\w`"\\[]|^)[a-z_][a-z0-9_]*(?=[^\\w`"(\\]]|$)#i', function ($m) use($driver) {
return strtoupper($m[0]) === $m[0] ? $m[0] : $driver->delimite($m[0]);
}, $s);
}
示例7: __construct
public function __construct($tableName, Connection $connection, IReflection $reflection)
{
$this->tableName = $tableName;
$this->databaseReflection = $reflection;
$this->driver = $connection->getSupplementalDriver();
$this->delimitedTable = $this->tryDelimite($tableName);
}
示例8: reloadForeignKeys
protected function reloadForeignKeys($table)
{
foreach ($this->connection->getSupplementalDriver()->getForeignKeys($table) as $row) {
$this->structure['belongsTo'][strtolower($table)][$row['local']] = $row['table'];
$this->structure['hasMany'][strtolower($row['table'])][$row['local'] . $table] = array($row['local'], $table);
}
if (isset($this->structure['belongsTo'][$table])) {
uksort($this->structure['belongsTo'][$table], function ($a, $b) {
return strlen($a) - strlen($b);
});
}
}
示例9: analyzeForeignKeys
protected function analyzeForeignKeys(&$structure, $table)
{
$lowerTable = strtolower($table);
foreach ($this->connection->getSupplementalDriver()->getForeignKeys($table) as $row) {
$structure['belongsTo'][$lowerTable][$row['local']] = $row['table'];
$structure['hasMany'][strtolower($row['table'])][$table][] = $row['local'];
}
if (isset($structure['belongsTo'][$lowerTable])) {
uksort($structure['belongsTo'][$lowerTable], function ($a, $b) {
return strlen($a) - strlen($b);
});
}
}
示例10: __construct
public function __construct(Connection $connection)
{
$this->connection = $connection;
$this->driver = $connection->getSupplementalDriver();
$this->arrayModes = array(
'INSERT' => $this->driver->isSupported(ISupplementalDriver::SUPPORT_MULTI_INSERT_AS_SELECT) ? 'select' : 'values',
'REPLACE' => 'values',
'UPDATE' => 'assoc',
'WHERE' => 'and',
'HAVING' => 'and',
'ORDER BY' => 'order',
'GROUP BY' => 'order',
);
}
示例11: buildSelectQuery
/**
* Returns SQL query.
*
* @return string
*/
public function buildSelectQuery()
{
$join = $this->buildJoins(implode(',', $this->conditions), true);
$join += $this->buildJoins(implode(',', $this->select) . ",{$this->group},{$this->having}," . implode(',', $this->order));
$prefix = $join ? "{$this->delimitedTable}." : '';
if ($this->select) {
$cols = $this->tryDelimite($this->removeExtraTables(implode(', ', $this->select)));
} elseif ($prevAccessed = $this->selection->getPreviousAccessed()) {
$cols = array_map(array($this->connection->getSupplementalDriver(), 'delimite'), array_keys(array_filter($prevAccessed)));
$cols = $prefix . implode(', ' . $prefix, $cols);
} else {
$cols = $prefix . '*';
}
return "SELECT{$this->buildTopClause()} {$cols} FROM {$this->delimitedTable}" . implode($join) . $this->buildConditions();
}
示例12: getPrimarySequence
/**
* @return string
*/
public function getPrimarySequence()
{
if ($this->primarySequence === FALSE) {
$this->primarySequence = NULL;
$driver = $this->connection->getSupplementalDriver();
if ($driver->isSupported(ISupplementalDriver::SUPPORT_SEQUENCE) && $this->primary !== NULL) {
foreach ($driver->getColumns($this->name) as $column) {
if ($column['name'] === $this->primary) {
$this->primarySequence = $column['vendor']['sequence'];
break;
}
}
}
}
return $this->primarySequence;
}
示例13: __construct
public function __construct(Connection $connection, $queryString, array $params)
{
$time = microtime(TRUE);
$this->connection = $connection;
$this->supplementalDriver = $connection->getSupplementalDriver();
$this->queryString = $queryString;
$this->params = $params;
if (substr($queryString, 0, 2) === '::') {
$connection->getPdo()->{substr($queryString, 2)}();
} elseif ($queryString !== NULL) {
$this->pdoStatement = $connection->getPdo()->prepare($queryString);
$this->pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
$this->pdoStatement->execute($params);
}
$this->time = microtime(TRUE) - $time;
}
示例14: detectColumnTypes
private function detectColumnTypes()
{
if ($this->types === null) {
$this->types = array();
if ($this->connection->getSupplementalDriver()->isSupported(ISupplementalDriver::META)) {
// workaround for PHP bugs #53782, #54695
$col = 0;
while ($meta = $this->getColumnMeta($col++)) {
if (isset($meta['native_type'])) {
$this->types[$meta['name']] = Helpers::detectType($meta['native_type']);
}
}
}
}
return $this->types;
}
示例15: detectColumnTypes
private function detectColumnTypes()
{
if ($this->types === NULL) {
$this->types = array();
if ($this->connection->getSupplementalDriver()->isSupported(ISupplementalDriver::SUPPORT_COLUMNS_META)) {
// workaround for PHP bugs #53782, #54695
$count = $this->columnCount();
for ($col = 0; $col < $count; $col++) {
$meta = $this->getColumnMeta($col);
if (isset($meta['native_type'])) {
$this->types[$meta['name']] = Helpers::detectType($meta['native_type']);
}
}
}
}
return $this->types;
}