I am using grep to find header info in a file and print it to another file. The header info only shows up on line 3 and 4 so i really don't need to search the remainder of the file. the grep -m option doesn't work with my version of UNIX. Also I'm new to UNIX so could you please explain what... (4 Replies)
Hi, I've been trying to figure this one out and found a post about this on the forum here but the solution didn't seem to work for me. Basically what I have is a file that looks something like:
stuff
morestuff
0
otherthing
0
etc
I want to substitute for the 0 but what I want to... (9 Replies)
hi
i have one file where i want to substitute only first instance of
swap
with swap1
i want to replcae only first instance of swap in my script
i know we can do this with awk. but i need to do this with sed only
i tried follwoing code
sed 's/swap/swap1' filename
but here all... (15 Replies)
Hi,
Here is my piece of code used with sed in shell script:
sed -i '/<falsemodule-option>/ a\<LdapLogin>' myxmlfile
The problem that i am facing with the above is that in 'myxml' file i have mulitple instances of <falsemodule-option>
so when i execute the above sed command, it is appending... (10 Replies)
I need to reduce a file's size below 50MB by deleting chucks of text. The following sed does this.
sed '/^begpattern/,/endpattern/d' myfile
However, it's possible that the file size can get below 50MB by just deleting the first instance of the pattern. How do I code that into sed?
Or can awk... (8 Replies)
I was told a way to do this with awk earlier today but is there a way with sed to specify the last instance of a character on a line?
You will know what character you're looking for but there could be none or one hundred instances of it on a line say and you ONLY want to specify the last one for... (3 Replies)
The following text is in testFile.txt:
one 5
two 10
three 15
four 20
five 25
six 10
seven 35
eight 10
nine 45
ten 50
I'd like to use sed to print the first occurance of search pattern /10/ in a given range. This command is to be run against large log files, so to optimize efficiency,... (9 Replies)
Hi all,
I'm new to the forum and also relatively new to sed and other such wonderfully epic tools.
I'm attempting to grab a section of text between two words, but it seems to match all instances of the range instead of stopping at just the first.
This occurs when I use:
sed -n... (7 Replies)
The intended result should be :
PDF converters
'empty line'
gpdftext and pdftotext?xml version="1.0"?>
xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters
gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies
LEARN ABOUT PHP
mysqli_affected_rows
MYSQLI_AFFECTED_ROWS(3) 1 MYSQLI_AFFECTED_ROWS(3)mysqli::$affected_rows - Gets the number of affected rows in a previous MySQL operation
Object oriented style
SYNOPSIS
int$mysqli->affected_rows ()
DESCRIPTION
Procedural style
int mysqli_affected_rows (mysqli $link)
Returns the number of rows affected by the last INSERT, UPDATE, REPLACE or DELETE query.
For SELECT statements mysqli_affected_rows(3) works like mysqli_num_rows(3).
PARAMETERS
o $
link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3)RETURN VALUES
An integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records were updated for an UPDATE
statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the query returned an
error.
Note
If the number of affected rows is greater than the maximum integer value(
PHP_INT_MAX ), the number of affected rows will be returned as a string.
EXAMPLES
Example #1
$mysqli->affected_rows example
Object oriented style
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
/* Insert rows */
$mysqli->query("CREATE TABLE Language SELECT * from CountryLanguage");
printf("Affected rows (INSERT): %d
", $mysqli->affected_rows);
$mysqli->query("ALTER TABLE Language ADD Status int default 0");
/* update rows */
$mysqli->query("UPDATE Language SET Status=1 WHERE Percentage > 50");
printf("Affected rows (UPDATE): %d
", $mysqli->affected_rows);
/* delete rows */
$mysqli->query("DELETE FROM Language WHERE Percentage < 50");
printf("Affected rows (DELETE): %d
", $mysqli->affected_rows);
/* select all rows */
$result = $mysqli->query("SELECT CountryCode FROM Language");
printf("Affected rows (SELECT): %d
", $mysqli->affected_rows);
$result->close();
/* Delete table Language */
$mysqli->query("DROP TABLE Language");
/* close connection */
$mysqli->close();
?>
Procedural style
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!$link) {
printf("Can't connect to localhost. Error: %s
", mysqli_connect_error());
exit();
}
/* Insert rows */
mysqli_query($link, "CREATE TABLE Language SELECT * from CountryLanguage");
printf("Affected rows (INSERT): %d
", mysqli_affected_rows($link));
mysqli_query($link, "ALTER TABLE Language ADD Status int default 0");
/* update rows */
mysqli_query($link, "UPDATE Language SET Status=1 WHERE Percentage > 50");
printf("Affected rows (UPDATE): %d
", mysqli_affected_rows($link));
/* delete rows */
mysqli_query($link, "DELETE FROM Language WHERE Percentage < 50");
printf("Affected rows (DELETE): %d
", mysqli_affected_rows($link));
/* select all rows */
$result = mysqli_query($link, "SELECT CountryCode FROM Language");
printf("Affected rows (SELECT): %d
", mysqli_affected_rows($link));
mysqli_free_result($result);
/* Delete table Language */
mysqli_query($link, "DROP TABLE Language");
/* close connection */
mysqli_close($link);
?>
The above examples will output:
Affected rows (INSERT): 984
Affected rows (UPDATE): 168
Affected rows (DELETE): 815
Affected rows (SELECT): 169
SEE ALSO mysqli_num_rows(3), mysqli_info(3).
PHP Documentation Group MYSQLI_AFFECTED_ROWS(3)