本文整理汇总了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);