本文整理匯總了PHP中mysql::query_assoc方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysql::query_assoc方法的具體用法?PHP mysql::query_assoc怎麽用?PHP mysql::query_assoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mysql
的用法示例。
在下文中一共展示了mysql::query_assoc方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generate_insert_query
function generate_insert_query($query)
{
preg_match("/FROM (.*?) /i", $query, $matches);
$table = $matches[1];
preg_match("/WHERE (.*) LIMIT/i", $query, $matches);
$where = $matches[1];
$query2 = "SELECT * FROM " . $table . " WHERE " . $where;
$row = mysql::query_assoc($query2);
foreach ($row as $key => $value) {
$values[] = "{$key}=\"{$value}\"";
}
$values2 = implode(", ", $values);
$insert = "INSERT INTO " . $table . " VALUES (" . $values2 . ")";
$insert2 = addslashes($insert);
$query3 = "INSERT INTO undo set query=\"{$insert2}\"";
// mysql::query_no_result($query3);
echo "insert query: <br>{$insert}";
exit;
}
示例2: json_encode
<?php
require 'mysql.php';
//Se instancia la clase en la variable $main
$main = new mysql();
$poll = $_POST["poll"];
$consult = "SELECT contenido FROM encuestas WHERE poll = '{$poll}'";
$res = $main->query_assoc($consult);
echo json_encode($res);
示例3: json_encode
<?php
require 'mysql.php';
$main = new mysql();
$consult = "SELECT DISTINCT C.poll FROM encuestas C";
echo json_encode($main->query_assoc($consult));
示例4: json_encode
<?php
require '../mysql.php';
$main = new mysql();
$con = "SELECT COUNT(*) FROM colonias";
$count = $main->query_assoc($con);
$Npags = $count[0]["COUNT(*)"] / 10;
$Npags = round($Npags);
$Npags = $Npags + 1;
$Npags = array('Npags' => $Npags);
$num = $_POST["num"];
if ($num != 0) {
$num--;
}
$num = $num * 10;
$consult = "SELECT * FROM colonias LIMIT {$num}, 10";
$res = $main->query_assoc($consult);
array_push($res, $Npags);
echo json_encode($res);
//echo json_encode($count);