My Sql Functions
. Mysql_afffected_rows() : this
function gets the number of affected rows in previous mysql operation(DML).
2. Mysql_data_seek(mysql result,in
$row_number) : this function is used for moving
internal result pointer.
Mysql_data_seek($rs,5);
Pointer
points to 6th record of my sql result.
3. Mysql_db_name(): returns
the database name on success or false on failure.
4. Mysql_list_dbs():
returns all the database names present in mysql database server as a resource
of type mysql result.
write a program to display all the
database names present in “localhost” mysql db server[mysql>show
databases;]?
<?php
echo
"<h1>";
error_reporting(E_ALL);
$con
= mysql_connect('localhost','root','');
$db_list
= mysql_list_dbs($con);
$i=0;
$cnt=
mysql_num_rows($db_list);
while($i<$cnt)
{
echo mysql_db_name($db_list,
$i)."<br>";
$i++;
}
mysql_close();
?>
OutPut:
information_schema
cdcol
emp
india
mysql
phpmyadmin
test
5.mysql_db_query(dbname,query):
this
function sends a mysql query to the specified database .in thes case no need of
using mysql_select_db() function explicitly.
$rs =
mysql_db_query(“employee”,”select * from emp”);
1. Mysql_fetch_field(mysql
result,column number): get column information from a
result type and return as an object. Returns an object containing field
informations.
0 comments:
Post a Comment