pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPL/pgSQL and PHP 5
6+ messages / 3 participants
[nested] [flat]
* PL/pgSQL and PHP 5
@ 2006-08-10 02:36 PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 03:24 ` Re: PL/pgSQL and PHP 5 John DeSoi <desoi@pgedit.com>
2006-08-10 03:40 ` Re: [SQL] PL/pgSQL and PHP 5 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: PostgreSQL Admin @ 2006-08-10 02:36 UTC (permalink / raw)
To: Lista PG-PHP <pgsql-php@postgresql.org>; +Cc: pgsql-sql
I'm having this problem inserting data from my form using PL/pgSQL.
Here is the simplified version of my table and function (this example
does not work, also ):
CREATE TABLE theirry.sample (
staff_id serial PRIMARY KEY NOT NULL,
firstname varchar(100),
lastname varchar(150),
username varchar(35),
identifier varchar(40),
address2 varchar(180),
activated boolean,
activated_keys varchar(32)
);
CREATE OR REPLACE FUNCTION insert_staff_b
(insert_firstname varchar)
RETURNS VOID AS
$$
DECLARE
BEGIN
INSERT INTO theirry.sample
(firstname)
VALUES
(insert_firstname);
RETURN;
END;
$$
LANGUAGE plpgsql;
I have a form with a value firstname then call the query in php
select insert_staff_b('$_POST['firstname']::varchar)
Still I get this error:
Warning: pg_query(): Query failed: ERROR: function
insert_staff_b(character varying) does not exist HINT: No function
matches the given name and argument types. You may need to add explicit
type casts.
Suggestions or maybe a place to read up on this problem.
Thanks in advance,
J
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PL/pgSQL and PHP 5
2006-08-10 02:36 PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
@ 2006-08-10 03:24 ` John DeSoi <desoi@pgedit.com>
2006-08-10 03:42 ` Re: PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
1 sibling, 1 reply; 6+ messages in thread
From: John DeSoi @ 2006-08-10 03:24 UTC (permalink / raw)
To: PostgreSQL Admin <postgres@productivitymedia.com>; +Cc: Lista PG-PHP <pgsql-php@postgresql.org>; pgsql-sql
On Aug 9, 2006, at 10:36 PM, PostgreSQL Admin wrote:
> select insert_staff_b('$_POST['firstname']::varchar)
>
>
> Still I get this error:
> Warning: pg_query(): Query failed: ERROR: function insert_staff_b
> (character varying) does not exist HINT: No function matches the
> given name and argument types. You may need to add explicit type
> casts.
Your select statement above has unbalanced single quotes. Assuming
this is not really the issue, I would check the search_path and look
at the function in psql or some admin tool to make sure the function
name does not have different capitalization.
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PL/pgSQL and PHP 5
2006-08-10 02:36 PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 03:24 ` Re: PL/pgSQL and PHP 5 John DeSoi <desoi@pgedit.com>
@ 2006-08-10 03:42 ` PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 06:12 ` Re: PL/pgSQL and PHP 5 John DeSoi <desoi@pgedit.com>
0 siblings, 1 reply; 6+ messages in thread
From: PostgreSQL Admin @ 2006-08-10 03:42 UTC (permalink / raw)
To: John DeSoi <desoi@pgedit.com>; +Cc: Lista PG-PHP <pgsql-php@postgresql.org>; pgsql-sql
Thanks for the catch. I've tried:
$connection->execute("SELECT
insert_staff_b('$staff[insert_firstname]'::varchar)");
$connection->execute("SELECT
insert_staff_b('".$staff['insert_firstname']."'::varchar)");
None work... I'm scratching my head on this one.
Thanks,
J
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PL/pgSQL and PHP 5
2006-08-10 02:36 PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 03:24 ` Re: PL/pgSQL and PHP 5 John DeSoi <desoi@pgedit.com>
2006-08-10 03:42 ` Re: PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
@ 2006-08-10 06:12 ` John DeSoi <desoi@pgedit.com>
0 siblings, 0 replies; 6+ messages in thread
From: John DeSoi @ 2006-08-10 06:12 UTC (permalink / raw)
To: PostgreSQL Admin <postgres@productivitymedia.com>; +Cc: Lista PG-PHP <pgsql-php@postgresql.org>; pgsql-sql
Glad you found the problem.
On Aug 9, 2006, at 11:42 PM, PostgreSQL Admin wrote:
> $connection->execute("SELECT insert_staff_b('$staff
> [insert_firstname]'::varchar)");
> $connection->execute("SELECT insert_staff_b('".$staff
> ['insert_firstname']."'::varchar)");
If you are creating SQL functions you want to call from PHP, you
might be interested in this simple class:
http://pgedit.com/resource/php/pgfuncall
Then instead of all the quoting issue you have above, you could
simply call your SQL function like a normal PHP method call:
$connection->insert_staff_b($staff['insert_firstname']);
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] PL/pgSQL and PHP 5
2006-08-10 02:36 PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
@ 2006-08-10 03:40 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-08-10 03:52 ` Re: [SQL] PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
1 sibling, 1 reply; 6+ messages in thread
From: Tom Lane @ 2006-08-10 03:40 UTC (permalink / raw)
To: PostgreSQL Admin <postgres@productivitymedia.com>; +Cc: Lista PG-PHP <pgsql-php@postgresql.org>; pgsql-sql
PostgreSQL Admin <postgres@productivitymedia.com> writes:
> CREATE OR REPLACE FUNCTION insert_staff_b
> (insert_firstname varchar)
> RETURNS VOID AS
> ...
> Still I get this error:
> Warning: pg_query(): Query failed: ERROR: function
> insert_staff_b(character varying) does not exist
Sure looks like it oughta work. One possibility is that you created the
function in a schema that isn't part of the application's search path.
Other than that, look for *really* silly errors, like not creating the
function in the same database the application is connected to ...
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] PL/pgSQL and PHP 5
2006-08-10 02:36 PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 03:40 ` Re: [SQL] PL/pgSQL and PHP 5 Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-08-10 03:52 ` PostgreSQL Admin <postgres@productivitymedia.com>
0 siblings, 0 replies; 6+ messages in thread
From: PostgreSQL Admin @ 2006-08-10 03:52 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Lista PG-PHP <pgsql-php@postgresql.org>; pgsql-sql
Tom Lane wrote:
> PostgreSQL Admin <postgres@productivitymedia.com> writes:
>
>> CREATE OR REPLACE FUNCTION insert_staff_b
>> (insert_firstname varchar)
>> RETURNS VOID AS
>> ...
>> Still I get this error:
>> Warning: pg_query(): Query failed: ERROR: function
>> insert_staff_b(character varying) does not exist
>>
>
> Sure looks like it oughta work. One possibility is that you created the
> function in a schema that isn't part of the application's search path.
> Other than that, look for *really* silly errors, like not creating the
> function in the same database the application is connected to ...
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>
I never thought of that. I look into it.
Thanks,
J
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2006-08-10 06:12 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-10 02:36 PL/pgSQL and PHP 5 PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 03:24 ` John DeSoi <desoi@pgedit.com>
2006-08-10 03:42 ` PostgreSQL Admin <postgres@productivitymedia.com>
2006-08-10 06:12 ` John DeSoi <desoi@pgedit.com>
2006-08-10 03:40 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-08-10 03:52 ` PostgreSQL Admin <postgres@productivitymedia.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox