function run() { $nIds = array(); $rs = sqlf("SHOW PROCESSLIST"); while ($r = msql_fetch_assoc($rs)) { $nIds[$r['Id']] = $r['Id']; } msql_free_result($rs); $rs = sqlf("SELECT DISTINCT `threadid` FROM `sys_temptables`"); while ($r = msql_fetch_assoc($rs)) { if (!isset($nIds[$r['threadid']])) { sqlf("DELETE FROM `sys_temptables` WHERE `threadid`='&1'", $r['threadid']); } } msql_free_result($rs); }
define('DB_USERNAME', 'root'); define('DB_PASSWORD', 'code4good'); define('DB_DATABASE', 'Implementation_new'); $connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error()); $database = mysql_select_db(DB_DATABASE) or die(mysql_error()); $sql = "SELECT p.name, p.address, p.current_budget, b.budget_consumed\nFROM project p\nINNER JOIN budget_tracking b ON p.project_id = b.project_id"; $result = mysql_query($sql, $connection); if (!$result) { echo "DB Error, could not query the database\n"; echo 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<table style='width:100%'><tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td><td> 50</td> </tr><tr><td>" . $row[2] . "</td><td>" . $row[3] . "</td><td> 50</td></tr></table>"; } msql_free_result($result); ?> <!-- <table style="width:100%"> <tr> <td>Project Name</td> <td>Budget</td> <td> 50</td> </tr> <tr> <td>Start Date</td> <td>Spent</td> <td> 50</td> </tr> </table>
/** * Returns information about a table or a result set * * @param object|string $result DB_result object from a query or a * string containing the name of a table. * While this also accepts a query result * resource identifier, this behavior is * deprecated. * @param int $mode a valid tableInfo mode * * @return array an associative array with the information requested. * A DB_Error object on failure. * * @see DB_common::setOption() */ function tableInfo($result, $mode = null) { if (is_string($result)) { /* * Probably received a table name. * Create a result resource identifier. */ $id = @msql_query("SELECT * FROM {$result}", $this->connection); $got_string = true; } elseif (isset($result->result)) { /* * Probably received a result object. * Extract the result resource identifier. */ $id = $result->result; $got_string = false; } else { /* * Probably received a result resource identifier. * Copy it. * Deprecated. Here for compatibility only. */ $id = $result; $got_string = false; } if (!is_resource($id)) { return $this->raiseError(DB_ERROR_NEED_MORE_DATA); } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $case_func = 'strtolower'; } else { $case_func = 'strval'; } $count = @msql_num_fields($id); $res = array(); if ($mode) { $res['num_fields'] = $count; } for ($i = 0; $i < $count; $i++) { $tmp = @msql_fetch_field($id); $flags = ''; if ($tmp->not_null) { $flags .= 'not_null '; } if ($tmp->unique) { $flags .= 'unique_key '; } $flags = trim($flags); $res[$i] = array('table' => $case_func($tmp->table), 'name' => $case_func($tmp->name), 'type' => $tmp->type, 'len' => msql_field_len($id, $i), 'flags' => $flags); if ($mode & DB_TABLEINFO_ORDER) { $res['order'][$res[$i]['name']] = $i; } if ($mode & DB_TABLEINFO_ORDERTABLE) { $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; } } // free the result only if we were called on a table if ($got_string) { @msql_free_result($id); } return $res; }
function sql_free_result($res) { global $dbtype; switch ($dbtype) { case "MySQL": $row = mysql_free_result($res); return $row; break; case "mSQL": $row = msql_free_result($res); return $row; break; case "postgres": case "postgres_local": $rows = pg_FreeResult($res->get_result()); return $rows; break; case "ODBC": case "ODBC_Adabas": $rows = odbc_free_result($res); return $rows; break; case "Interbase": echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>"; return $rows; break; case "Sybase": $rows = sybase_free_result($res); return $rows; break; } }
function freeResult($result) { return @msql_free_result($result); }
function freeResult($result) { if (is_resource($result)) { return @msql_free_result($result); } if (!isset($this->prepare_tokens[$result])) { return false; } unset($this->prepare_tokens[$result]); unset($this->prepare_types[$result]); return true; }
function FreeResult($result) { unset($this->highest_fetched_row[$result]); unset($this->columns[$result]); unset($this->limits[$result]); unset($this->result_types[$result]); return msql_free_result($result); }