本文整理汇总了PHP中DBUtils::executeQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtils::executeQuery方法的具体用法?PHP DBUtils::executeQuery怎么用?PHP DBUtils::executeQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtils
的用法示例。
在下文中一共展示了DBUtils::executeQuery方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createIfNotExist
private function createIfNotExist()
{
$questionsTableQuery = "CREATE TABLE IF NOT EXISTS `questions` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `intrebare` text NOT NULL,\n `r1text` varchar(200) NOT NULL DEFAULT 'Da',\n `r2text` varchar(200) NOT NULL DEFAULT 'Nu',\n `r3text` varchar(200) NOT NULL DEFAULT 'Nu cunosc setarea',\n `r1Val` int(10) NOT NULL DEFAULT '1',\n `r2Val` int(11) NOT NULL DEFAULT '0',\n `r3Val` int(10) NOT NULL DEFAULT '0',\n `r1Sugestie` text,\n `r2Sugestie` text,\n `r3Sugestie` text,\n `creation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n `single_choice` int(11) NOT NULL DEFAULT '1',\n `page_index` int(11) NOT NULL DEFAULT '0',\n `page_title` varchar(200) NOT NULL DEFAULT 'pagina 1',\n `page_subtitle` varchar(200) NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
DBUtils::executeQuery($questionsTableQuery);
$pointsMapQuery = "CREATE TABLE IF NOT EXISTS `points_map` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `punctaj` int(11) DEFAULT NULL,\n `mesaj` varchar(5000) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `punctaj` (`punctaj`)\n ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
DBUtils::executeQuery($pointsMapQuery);
$rapoarteTable = "CREATE TABLE IF NOT EXISTS `rapoarte` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `industrie` varchar(200) DEFAULT NULL,\n `email` varchar(200) DEFAULT NULL,\n `sugestii` int(11) NOT NULL,\n `telefon` varchar(12) NOT NULL,\n `data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n `nume` varchar(200) NOT NULL,\n `punctaj` int(11) DEFAULT NULL,\n `website` varchar(300) NOT NULL,\n `textRaport` text,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=149 ;";
DBUtils::executeQuery($rapoarteTable);
}
示例3: json_encode
$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);
echo json_encode($response);
示例4: array
// echo $loader->getNumQuestions($pageIndex);
$qsTxt = '';
for ($i = 0; $i < $loader->getNumQuestions($pageIndex); $i++) {
$qsTxt .= TemplateEngine::mustacheRenderFile(Utils::getQuestionsViewPath(), $loader->getQuestion($i, $pageIndex));
}
echo TemplateEngine::mustacheRender(Utils::getPageViewContent(), array('questions' => $qsTxt, 'pageTitle' => $loader->getPageTitle($pageIndex), 'pageIndex' => $pageIndex, 'nextPage' => $pageIndex + 1, 'numQuestions' => $loader->getNumQuestions($pageIndex), 'isLastPage' => $loader->isLastPage(intval($pageIndex)), 'pageSubtitle' => $loader->getPageSubtitle($pageIndex)));
} else {
if ($nextPage == 'thanksPage') {
$answerData = Utils::digestAnswers($_SESSION, $quizzEngine);
$htmlMessage = TemplateEngine::mustacheRenderFile('./views/finalReport.html', $answerData);
// echo $htmlMessage;
$receiveSugestions = 0;
if (isset($_SESSION['primestesugestii'])) {
$receiveSugestions = $_SESSION['primestesugestii'] == 'on' ? 1 : 0;
}
$id = DBUtils::executeQuery($insertReportStatement, $_SESSION['nume'], $_SESSION['industrie'], $_SESSION['email'], $receiveSugestions, $_SESSION['telefon'], $_SESSION['completedAnswers'], $_SESSION['website'], $htmlMessage);
require 'app/core/libs/PHPMailer/PHPMailerAutoload.php';
// echo $htmlMessage;
$mail = new PHPMailer();
$mail->isSMTP();
$mail->setFrom('admin@todaysquizz.ro', 'Admin');
$mail->addAddress($_SESSION['email'], 'User');
$mail->isHTML(true);
$mail->Subject = 'Raport quizz todays';
$mail->Body = $htmlMessage;
if (!$mail->send()) {
$mailStat = 'Raportul nu a fost trimis: ';
$mailSubStat = $mail->ErrorInfo;
} else {
$mailStat = 'Raportul a fost trimis cu succes';
$mailSubStat = 'Il vei primi pe mail in cateva momente';
示例5: editRowForm
public static function editRowForm($tableName, $selectorName = NULL, $whereValue = NULL, $action, $assocs)
{
if ($selectorName == NULL && $whereValue == NULL) {
$result = DBUtils::executeQuery("SELECT * FROM " . $tableName);
} else {
$result = DBUtils::executeQuery("SELECT * FROM " . $tableName . " WHERE " . $selectorName . " = ? LIMIT 1;", $whereValue);
}
$resultxt = '<form id="questionEditForm" method=POST action="' . $action . '">';
foreach ($result as $value) {
foreach ($value as $key => $subvalue) {
if (is_string($key)) {
$resultxt .= '<label>' . $key . '</label>:';
if ($key === $selectorName) {
$resultxt .= '<input name="' . $key . '" type=text value="' . $subvalue . '" readonly/><br/>';
} else {
if (isset($assocs[$key]) && $assocs[$key] === 'textarea-html') {
$resultxt .= '<textarea name="' . $key . '" class="html-content">' . $subvalue . '</textarea><br/>';
} else {
if (isset($assocs[$key]) && $assocs[$key] === 'readonly') {
$resultxt .= '<input name="' . $key . '" type=text value="' . $subvalue . '" readonly/><br/>';
} else {
$resultxt .= '<input name="' . $key . '" type=text value="' . $subvalue . '"/><br/>';
}
}
}
}
}
}
if (isset($assocs['submitDirect'])) {
$resultxt .= $assocs['submitDirect'];
}
$resultxt .= '</form>';
if (isset($assocs['submitFree'])) {
$resultxt .= $assocs['submitFree'];
}
return $resultxt;
}