mysql_affected_rows

mysql_affected_rows -- Get number of affected rows in previous MySQL operation

Description

int mysql_affected_rows ( [resource link_identifier])

הערה :

הערה :

דוגמה 1 .

 
?php

 
/

 
*

 
connect

 
to

 
database

 
*

 
/

 
mysql_pconnect(

 
"localhost"

 
,

 
"mysql_user"

 
,

 
"mysql_password"

 
)

 
or

 
die

 
("Could

 
not

 
connect")

 
;

 
/

 
*

 
this

 
should

 
return

 
the

 
correct

 
numbers

 
of

 
deleted

 
records

 
*

 
/

 
mysql_query("DELETE

 
FROM

 
mytable

 
WHERE

 
id

 
10")

 
;

 
printf

 
("Records

 
deleted

 
:

 
%d\n"

 
,

 
mysql_affected_rows())

 
;

 
/

 
*

 
without

 
a

 
where

 
clause

 
in

 
a

 
delete

 
statement

 
,

 
it

 
should

 
return

 
0

 
*

 
/

 
mysql_query("DELETE

 
FROM

 
mytable")

 
;

 
printf

 
("Records

 
deleted

 
:

 
%d\n"

 
,

 
mysql_affected_rows())

 
;

 
?
















דוגמה 2 .

 
?php

 
/

 
*

 
connect

 
to

 
database

 
*

 
/

 
mysql_pconnect(

 
"localhost"

 
,

 
"mysql_user"

 
,

 
"mysql_password"

 
)

 
or

 
die

 
("Could

 
not

 
connect")

 
;

 
/

 
*

 
Update

 
records

 
*

 
/

 
mysql_query("UPDATE

 
mytable

 
SET

 
used=1

 
WHERE

 
id

 
10")

 
;

 
printf

 
("Updated

 
records

 
:

 
%d\n"

 
,

 
mysql_affected_rows())

 
;

 
mysql_query("COMMIT")

 
;

 
?