I have a little script to help me manage a gallery of image files. It makes symbolic links to every file in and below the current directory, placing them in a target directory which is passed to the script as a parameter. Unfortunately, the script pukes when I pass a parameter that contains... (4 Replies)
If have
var='$variable'
how can I expand $variable.
I have tried many thing like duble quotes/braces etc, but nothing worked.
I need the solution ASAP. (2 Replies)
Hi,
The following code finds the line containing fruits in test.txt and replaces instances of apple with banana.
ed -s test.txt <<< $'/fruits/s/apple/banana/g\nw'
What I want to do is put variables in the place of fruits, apple and banana.
I have tried replacing ' with " to get... (2 Replies)
Hi,
I need some direction with the following. The below code is semi-psuedo code which will hopefully make it easier to understand what I am trying to achieve:
for i in `echo ${testarray
}`
do
let c=c+1
eval "first$c=$i"
while... (4 Replies)
Hello,
so i'm making a script, using dynamic variables and trying to expand them. So far it hasn't worked out too well so it seems that I need some help from you, the elite.
Example:
#!/bin/sh
counter=0
until (($counter>5))
counter2=1
until (($counter2>6)); do
if ;... (5 Replies)
Hi Guys,
I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need.
I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles.
... (3 Replies)
My OS is Linux (kernel 4.08.something) and AIX (7100-04-01-1543), the used ksh versions are:
ksh88: Version M-11/16/88f (AIX)
ksh93: Version M 93t+ 2009-05-01 (AIX), Version M 93u (Linux)
When writing a parser for stanza files in ksh i encountered a rather strange behavior. Here is a... (4 Replies)
I pass an argument to bash as run. The first command in green executes as expected, however the second in blue fails as the $run does not expand. I tried to escape the variable with \ thinking the quotes were making the literal translation and also "${run}" but both did not work to expand the... (3 Replies)
Discussion started by: cmccabe
3 Replies
LEARN ABOUT PHP
pg_fetch_array
PG_FETCH_ARRAY(3)PG_FETCH_ARRAY(3)pg_fetch_array - Fetch a row as an arraySYNOPSIS
array pg_fetch_array (resource $result, [int $row], [int $result_type = PGSQL_BOTH])
DESCRIPTION pg_fetch_array(3) returns an array that corresponds to the fetched row (record).
pg_fetch_array(3) is an extended version of pg_fetch_row(3). In addition to storing the data in the numeric indices (field number) to the
result array, it can also store the data using associative indices (field name). It stores both indicies by default.
Note
This function sets NULL fields to the PHP NULL value.
pg_fetch_array(3) is NOT significantly slower than using pg_fetch_row(3), and is significantly easier to use.
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
o $row
- Row number in result to fetch. Rows are numbered from 0 upwards. If omitted or NULL, the next row is fetched.
o $result_type
- An optional parameter that controls how the returned array is indexed. $result_type is a constant and can take the following
values: PGSQL_ASSOC, PGSQL_NUM and PGSQL_BOTH. Using PGSQL_NUM, pg_fetch_array(3) will return an array with numerical indices,
using PGSQL_ASSOC it will return only associative indices while PGSQL_BOTH, the default, will return both numerical and associa-
tive indices.
RETURN VALUES
An array indexed numerically (beginning with 0) or associatively (indexed by field name), or both. Each value in the array is represented
as a string. Database NULL values are returned as NULL.
FALSE is returned if $row exceeds the number of rows in the set, there are no more rows, or on any other error.
EXAMPLES
Example #1
pg_fetch_array(3) example
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occurred.
";
exit;
}
$result = pg_query($conn, "SELECT author, email FROM authors");
if (!$result) {
echo "An error occurred.
";
exit;
}
$arr = pg_fetch_array($result, 0, PGSQL_NUM);
echo $arr[0] . " <- Row 1 Author
";
echo $arr[1] . " <- Row 1 E-mail
";
// As of PHP 4.1.0, the row parameter is optional; NULL can be passed instead,
// to pass a result_type. Successive calls to pg_fetch_array will return the
// next row.
$arr = pg_fetch_array($result, NULL, PGSQL_ASSOC);
echo $arr["author"] . " <- Row 2 Author
";
echo $arr["email"] . " <- Row 2 E-mail
";
$arr = pg_fetch_array($result);
echo $arr["author"] . " <- Row 3 Author
";
echo $arr[1] . " <- Row 3 E-mail
";
?>
SEE ALSO pg_fetch_row(3), pg_fetch_object(3), pg_fetch_result(3).
PHP Documentation Group PG_FETCH_ARRAY(3)