Alt-PHP-Faq

Vitamin Supplements| Cortavet| Cortaflex| Cortaflex| Health Supplements| Equine Supplements| Manuka Honey| Fat Loss 4 Idiots| Explosive Cashins CB Traffic Warrior Freedom Blogging Profit The Profit Spy Push Button Monkey GPunisher Blogging Syndicate Content Lockdown Turbo Commissions Auto Cash Funnel Traffic Reloaded Affiliate Scalper Mass Money Makers


Question :

Is there a library of SQL functions that I can just include?

Answer :

<?
/* do a MySQL query */
function do_query ($query$db_link) {

    
$result = @mysql_query($query$db_link);
    if (!
$result) {
        
fatal_error("A database query error has occurred!");
    } else {
        return(
$result);
    }
    
}

/* get single result value */
function query2result ($query$db_link) {

    
$result do_query($query$db_link);
    
$row = @mysql_result($result0);
    return(
$row);

}

/* get result in numeric array */
function query2array ($query$db_link) {

    
$result do_query($query$db_link);
    
$row = @mysql_fetch_row($result);
    return(
$row);

}

/* get result in associative array */
function query2hash ($query$db_link) {

    
$result do_query($query$db_link);
    
$row = @mysql_fetch_array($result);
    return(
$row);
    
}

/* get row of result */
function result2row ($result) {

    
$row = @mysql_fetch_row($result);
    return(
$row);

}

/* get row of result in hash */
function result2hash ($result) {

    
$row = @mysql_fetch_array($result);
    return(
$row);

}

/* find number of rows in query result */
function number_rows ($result) {

    
$number_rows = @mysql_num_rows($result);
    return(
$number_rows);

}

/* put rows from a column into an array */
function column2array ($query$db_link) {

    
$result do_query($query$db_link);
    while (
$row = @mysql_fetch_array($result)) {
        
$array[] = $row[0];
    }
    return(
$array);

}
?>



Categories Return to Main PHP Faq

SQL


 

Questions

SQL
I have lost my MySQL root password, how can I get in?
Is it possible to move my mysql database to another server?
How can I manage a MySQL database from windows?
Where can I find a database of country codes?
I am trying to create a database and keep getting an error :- (Errcode: 28)
 

Return to the main FAQ list



Design & Layout Copyright © 2000- 2008 PHP MySQL Web Hosting Comments to Webmaster
Hosted by PHP 4 Hosting - PHP and MySQL Webhosting and Domain Names