I know htis isnt exactly unix.... but hopefully someone can help me or direct me someplace to get help.
I can run sql queries in scripts against my informix db using:
dbaccess mydb myquery.sql >> sql.output
I need to write my script to select based on todays date. Its very... (5 Replies)
Hi Folks,
This is a small chunk of the bigger problem which i am facing and some help here will help me resolve the rest of the issue.
Problem is that i need to pass the value of a variable from a shell script to a SQL query (infact a lot of SQL's)
i have the following solution but somehow... (4 Replies)
I created a script to read a csv file with four columns. The script also saved values of each col in a arry.
In the script, i connected to db try to run a query to pull out data baisc on the values from the csv file.
select Num from tableName
where Sec_Num in ('${isin}') /*isin is an arry... (1 Reply)
Unix prompt
=========
echo "Enter the query"
read q
==========
User has entered :
SELECT * FROM employee
=====================
Now the problem starts..
echo $q
Output: SELECT "all files names in the PWD" FROM employee
================================================
... (5 Replies)
I have a script (say script1.sh ) and I am calling a script (say script2.sh) within the script1.sh. Here in script1.sh I have a hash ( say %hash1) and i have to pass this hash to script2.sh. Basically i have to do some processing in Scirpt2.sh based on the hash(key,values). I wanted to know how can... (2 Replies)
I heard this was possible but from my research I haven't been able to figure it out yet. Seems it should be simple enough. Basically from a high level view I'm trying to accomplish...
. $X='grep foo blah.log'
then 'mysql command SELECT foo FROM bar WHERE ' . $X
or something like that.
... (2 Replies)
hi there
I have the following script in which i have created a PrintHash() function.
I want to pass to this function the reference to a hash (in the final code i will be passing different hashes to this print function hence the need for a function). I am getting an error
Type of arg 1 to... (1 Reply)
How to pass variable to sql file.
Im tryin in two ways,
Method 1:
my.sql
select * from table where col1 = '$1' and col2 = 'text';
Method 1execute: dbaccess database my.sql $var
Method2:
select * from table col1 in (`cat inputfile`) and col2 = 'text';
method... (2 Replies)
I have a script in which i connect to database to run a query and get the result of the query to a temp file. This works fine , now what i want is there is flat file which contains the value to be used in the query. I want to read this file line by line and then run the query for each value in that... (7 Replies)
Hi,
I have created a shell script that reads line from text file and insert into DB table. I have used IFS to separate the line text. Looks IFS is splitting text properly but while passing one of the values that has special characters in it to query, it is giving weird issue. Below is my... (2 Replies)
Discussion started by: yuvi
2 Replies
LEARN ABOUT PHP
pdostatement.bindparam
PDOSTATEMENT.BINDPARAM(3) 1 PDOSTATEMENT.BINDPARAM(3)PDOStatement::bindParam - Binds a parameter to the specified variable name
SYNOPSIS
public bool PDOStatement::bindParam (mixed $parameter, mixed &$variable, [int $data_type = PDO::PARAM_STR], [int $length], [mixed
$driver_options])
DESCRIPTION
Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.
Unlike PDOStatement.bindValue(3), the variable is bound as a reference and will only be evaluated at the time that PDOStatement.execute(3)
is called.
Most parameters are input parameters, that is, parameters that are used in a read-only fashion to build up the query. Some drivers support
the invocation of stored procedures that return data as output parameters, and some also as input/output parameters that both send in data
and are updated to receive it.
PARAMETERS
o $parameter
- Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form $:name. For a
prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter.
o $variable
- Name of the PHP variable to bind to the SQL statement parameter.
o $data_type
- Explicit data type for the parameter using the PDO::PARAM_* constants. To return an INOUT parameter from a stored procedure, use
the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the $data_type parameter.
o $length
- Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the
length.
o $driver_options
-
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Execute a prepared statement with named placeholders
<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour');
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);
$sth->execute();
?>
Example #2
Execute a prepared statement with question mark placeholders
<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->bindParam(1, $calories, PDO::PARAM_INT);
$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);
$sth->execute();
?>
Example #3
Call a stored procedure with an INOUT parameter
<?php
/* Call a stored procedure with an INOUT parameter */
$colour = 'red';
$sth = $dbh->prepare('CALL puree_fruit(?)');
$sth->bindParam(1, $colour, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->execute();
print("After pureeing fruit, the colour is: $colour");
?>
SEE ALSO PDO.prepare(3), PDOStatement.execute(3), PDOStatement.bindValue(3).
PHP Documentation Group PDOSTATEMENT.BINDPARAM(3)