本文整理汇总了PHP中mysql_free_result函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_free_result函数的具体用法?PHP mysql_free_result怎么用?PHP mysql_free_result使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_free_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select
/**
* 功能:数据库查询函数
* 参数:¥sql SQL语句
* 返回:二维数组或false
*/
public function select($sql = "")
{
if (empty($sql)) {
return false;
//如果sql语句为空则返回false
}
if (empty($this->CONN)) {
return false;
//如果连接为空返回false
}
try {
$results = mysql_query($sql, $this->CONN) or die("Invalid query: " . mysql_error());
} catch (Exception $e) {
$msg = $e;
include ROOT_PATH . ERRORFILE;
}
if (!$results or empty($results)) {
@mysql_free_result($results);
//如果查询结果为空则释放结果并返回false
return false;
}
$count = 0;
$data = array();
while ($row = @mysql_fetch_array($results)) {
$data[$count] = $row;
$count++;
}
@mysql_free_result($results);
return $data;
}
示例2: __destruct
public function __destruct()
{
if (is_resource($this->_result))
{
mysql_free_result($this->_result);
}
}
示例3: _icl_ts_mysqldump
function _icl_ts_mysqldump($mysql_database)
{
global $wpdb;
$upload_folder = wp_upload_dir();
$dump_tmp_file = $upload_folder['path'] . '/' . '__icl_mysqldump.sql';
$fp = @fopen($dump_tmp_file, 'w');
if (!$fp) {
$fp = fopen('php://output', 'w');
ob_start();
}
$sql = "SHOW TABLES LIKE '" . str_replace('_', '\\_', $wpdb->prefix) . "%';";
$result = mysql_query($sql);
if ($result) {
while ($row = mysql_fetch_row($result)) {
//_icl_ts_mysqldump_table_structure($row[0]);
//_icl_ts_mysqldump_table_data($row[0]);
_icl_ts_backup_table($row[0], 0, $fp);
}
} else {
echo "/* no tables in {$mysql_database} */\n";
}
mysql_free_result($result);
fclose($fp);
if (file_exists($dump_tmp_file)) {
$data = file_get_contents($dump_tmp_file);
@unlink($dump_tmp_file);
} else {
$data = ob_get_contents();
ob_end_clean();
}
return $data;
}
示例4: get_taxes
public static function get_taxes($zip)
{
$server = 'db.Zip2Tax.com';
$username = 'z2t_link';
$password = 'H^2p6~r';
$database = 'zip2tax';
$connection = mysql_connect($server, $username, $password, 0, 65536);
if (!$connection) {
return;
}
$selected = mysql_select_db($database, $connection);
if (!$selected) {
return;
}
$username = 'sample';
$password = 'password';
$query = mysql_query("CALL {$database}.z2t_lookup('{$zip}','{$username}','{$password}')");
if (!$query) {
return;
}
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
echo "Zip Code: " . $row['Zip_Code'] . "<br>";
echo "Sales Tax Rate: " . $row['Sales_Tax_Rate'] . "<br>";
echo "Post Office City: " . $row['Post_Office_City'] . "<br>";
echo "County: " . $row['County'] . "<br>";
echo "State: " . $row['State'] . "<br>";
echo "Shipping Taxable: " . $row['Shipping_Taxable'] . "<br>";
}
mysql_free_result($query);
mysql_close($connection);
}
示例5: dbQuery
function dbQuery ( $query ) {
#----------------------------------------------------------------------
startTimer();
if( wcaDebug() ){
startTimer();
global $dbQueryCtr;
$dbQueryCtr++;
echo "\n\n<!-- dbQuery(\n$query\n) -->\n\n";
echo "<br>";
stopTimer( 'printing the database query' );
}
startTimer();
$dbResult = mysql_query( $query )
or showDatabaseError( "Unable to perform database query." );
stopTimer( "pure database query" );
startTimer();
$rows = array();
while( $row = mysql_fetch_array( $dbResult ))
$rows[] = $row;
stopTimer( "fetching database query results" );
startTimer();
mysql_free_result( $dbResult );
stopTimer( "freeing the mysql result" );
global $dbQueryTotalTime;
$dbQueryTotalTime += stopTimer( "the whole dbQuery execution" );
return $rows;
}
示例6: login
function login($clave)
{
$sqllogin = "SELECT idalumno, numcontrol,nombre FROM talumnos WHERE numcontrol = '" . $_POST["numcontrol"] . "'";
$qConsulta = mysql_query($sqllogin);
if ($fila = mysql_fetch_object($qConsulta)) {
$idalumno = $fila->idalumno;
mysql_free_result($qConsulta);
$sqllogin = "SELECT idexamen FROM texamenes WHERE claveexamen = '" . $_POST["idexamen"] . "'";
$qConsulta = mysql_query($sqllogin) or die("error: " . $sqllogin);
if ($fila2 = mysql_fetch_object($qConsulta)) {
$idexamen = $fila2->idexamen;
$sExam = "SELECT idexamen FROM tans1 WHERE idalumno= " . $idalumno . " AND idexamen = " . $idexamen;
$req = mysql_query($sExam) or die("error: " . $sExam);
if (mysql_fetch_object($req)) {
return $this->login_form(traducir_cadena("already_registered"));
exit;
}
setcookie("logged", $_POST["sessionid"]);
session_start();
$_SESSION['usuario'] = 'alumno';
$_SESSION['sessionid'] = $_POST["sessionid"];
$_SESSION['numcontrol'] = $_POST["numcontrol"];
$_SESSION['idexamen'] = $_POST["idexamen"];
header("Location: exam.php");
} else {
return $this->login_form(traducir_cadena(FORM_ERROR), $clave);
}
} else {
return $this->login_form(traducir_cadena(FORM_ERROR), $clave);
}
}
示例7: free
function free()
{
if ($this->_handle) {
mysql_free_result($this->_handle);
}
$this->_handle = null;
}
示例8: consulta
function consulta()
{
$servidor = 'localhost';
$usuario = 'root';
$senha = '';
$banco = 'safd';
$conexao = mysql_connect($servidor, $usuario, $senha, $banco);
if (!($link = mysql_connect($servidor, $usuario, $senha))) {
echo 'Não foi possível conectar ao mysql';
exit;
}
if (!mysql_select_db($banco, $link)) {
echo 'Não foi possível selecionar o banco de dados';
exit;
}
$sql = 'SELECT * FROM usuarios';
$result = mysql_query($sql, $link);
if (!$result) {
echo "Erro do banco de dados, não foi possível consultar o banco d dados\n";
echo "Erro MySQL: " . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
$visualizar = "<tr>\n <td>" . $row['id'] . "</td>" . "\n <td>" . $row['nome_completo'] . "</td>" . "\n <td>" . $row['email'] . "</td>" . "\n <td>" . $row['setor'] . "</td>" . "\n <td>" . $row['funcao'] . "</td>" . "\n <td>\n <ul > Excluir </ul>\n </td>" . "\n </tr>";
/*
$usuarios = consulta_todos_usuarios();
echo $usuarios;
*/
echo $visualizar;
}
mysql_free_result($result);
}
示例9: show_platforms
function show_platforms()
{
$path = "../cache/platform_list.xml";
$mtime = @filemtime($path);
if ($mtime && time() - $mtime < 3600) {
@readfile($path);
} else {
require_once "../inc/db.inc";
$retval = db_init_aux(true);
if (!$retval) {
$query = 'select name, user_friendly_name, plan_class from platform, app_version where app_version.platformid = platform.id and app_version.deprecated=0 group by name, plan_class';
$result = mysql_query($query);
$f = fopen($path, "w");
fwrite($f, "<platforms>\n");
while ($p = mysql_fetch_object($result)) {
if ($p->plan_class) {
$pc = " <plan_class>{$p->plan_class}</plan_class>\n";
} else {
$pc = "";
}
fwrite($f, " <platform>\n <platform_name>{$p->name}</platform_name>\n <user_friendly_name>{$p->user_friendly_name}</user_friendly_name>\n{$pc} </platform>\n");
}
mysql_free_result($result);
fwrite($f, "</platforms>\n");
fclose($f);
@readfile($path);
}
}
}
示例10: konsultar
function konsultar($consulta,$var1,$var2){
$enlace = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('No pudo conectarse : ' . mysql_error());
mysql_select_db(DB_NAME,$enlace) or die('No pudo seleccionarse la BD.');
$sql=$consulta;
$resultado = mysql_query($sql,$enlace) or die('La consulta falló: ' . mysql_error());
while ($row = mysql_fetch_array($resultado)){
if($var1=="id" ){
$iduser=$row[0];
}elseif($var1=="estado"){
$estado=$row[0];
}
elseif($var1=="idmarca"){
$idmarca=$row[0];
}
}
mysql_free_result($resultado);
if($var1=="id"){
return $iduser;
}
elseif($var1=="estado"){
return $estado;
}
elseif($var1=="idmarca"){
return $idmarca;
}
}
示例11: processQuery
public function processQuery($sql, $type = NULL)
{
$query_start = microtime(true);
$result = mysql_query($sql, $this->db);
$query_end = microtime(true);
$this->log($sql, $query_end - $query_start);
$this->checkForError();
$data = array();
if (is_resource($result)) {
$resultType = MYSQL_NUM;
if ($type == 'assoc') {
$resultType = MYSQL_ASSOC;
}
while ($row = mysql_fetch_array($result, $resultType)) {
if (mysql_affected_rows($this->db) > 1) {
array_push($data, $row);
} else {
$data = $row;
}
}
mysql_free_result($result);
} else {
if ($result) {
$data = mysql_insert_id($this->db);
}
}
return $data;
}
示例12: alertnoticias_consultar
function alertnoticias_consultar($consulta,$accion)
{
$enlace = mysql_connect('atc-nh-natsdb.nationalnet.com', 'staffcenter','XgwofvLY2ayLf') or die('No pudo conectarse : ' . mysql_error());
mysql_select_db('staffcenter',$enlace) or die('No pudo seleccionarse la BD.');
$sql = $consulta;
$resultado = mysql_query($sql,$enlace) or die('La consulta falló: ' . mysql_error());
while ($row = mysql_fetch_array($resultado)){
switch($accion)
{
case "noticiasdeldia":
$idsnoticias[]=$row['idnoticia'].",".$row['titulo'];
break;
}
}
mysql_free_result($resultado);
switch($accion)
{
case "noticiasdeldia":
return $idsnoticias;
break;
}
}
示例13: query
public function query($sql)
{
if ($this->link) {
$resource = mysql_query($sql, $this->link);
if ($resource) {
if (is_resource($resource)) {
$i = 0;
$data = array();
while ($result = mysql_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
mysql_free_result($resource);
$query = new \stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
unset($data);
return $query;
} else {
return true;
}
} else {
$trace = debug_backtrace();
trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $trace[1]['file'] . '</b> line <b>' . $trace[1]['line'] . '</b><br />' . $sql);
}
}
}
示例14: getCacheNote
public function getCacheNote($userid, $cacheid)
{
$rs = sql("SELECT id, latitude, longitude, description FROM coordinates WHERE user_id = &1 AND cache_id = &2 AND type = &3", $userid, $cacheid, Coordinate_Type::UserNote);
$ret = $this->recordToArray(sql_fetch_array($rs));
mysql_free_result($rs);
return $ret;
}
示例15: query
public function query($sql)
{
$resource = mysql_query($sql, $this->link);
if ($resource) {
if (is_resource($resource)) {
$i = 0;
$data = array();
while ($result = mysql_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
mysql_free_result($resource);
$query = new stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
unset($data);
return $query;
} else {
return true;
}
} else {
trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql);
exit;
}
}