本文整理匯總了PHP中DBUtils::getActiveConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBUtils::getActiveConnection方法的具體用法?PHP DBUtils::getActiveConnection怎麽用?PHP DBUtils::getActiveConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBUtils
的用法示例。
在下文中一共展示了DBUtils::getActiveConnection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generateSelectQuery
private function generateSelectQuery()
{
$this->selectQuery = 'SELECT ';
$this->selectQuery .= implode(', ', $this->tableSelectedFields);
$this->selectQuery .= ' FROM ' . $this->tableName;
if ($this->conditions != NULL) {
$eqConditions = ' WHERE ';
for ($i = 0; $i < count($this->conditions); $i++) {
$value = $this->conditions[$i];
$eqConditions .= $value['field'] . '=' . DBUtils::getActiveConnection()->quote($value['value']);
if ($i < count($this->conditions) - 1) {
$eqConditions .= ' AND ';
}
}
$this->selectQuery .= $eqConditions . ';';
}
$data = DBUtils::executeQuery($this->selectQuery, DBUtils::$PDO_MODE_ASSOC);
foreach ($data as $dkey => $entry) {
foreach ($entry as $key => $value) {
$oldVal = $value;
$data[$dkey][$key] = array('value' => $value, 'tag' => $this->fields[$key]['tag'], 'mode' => $this->fields[$key]['mode'], 'type' => $this->fields[$key]['type']);
}
}
return $data;
}
示例2: array
if ($_POST['action'] === 'update') {
$query = 'UPDATE ' . $_POST['tableName'] . ' SET ' . $r . $w;
} else {
if ($_POST['action'] === 'delete') {
$query = 'DELETE FROM ' . $_POST['tableName'] . $w;
} else {
if ($_POST['action'] === 'insert') {
if (isset($_POST['insert'])) {
$query = 'INSERT INTO ' . $_POST['tableName'];
$keys = '(';
$values = '(';
for ($i = 0; $i < count($_POST['insert']); $i++) {
$value = $_POST['insert'][$i];
if (isset($value['value'])) {
$keys .= $value['key'];
$values .= DBUtils::getActiveConnection()->quote($value['value']);
if ($i < count($_POST['insert']) - 1) {
$keys .= ',';
$values .= ',';
}
}
}
$keys .= ')';
$values .= ')';
$query .= $keys . ' VALUES ' . $values;
}
}
}
}
DBUtils::executeQuery($query);
$response = array('status' => 'success', 'query' => $query);