Re: [PHP-DB] postgresql field size information

2004-05-27 Thread Cornelia Boenigk
Hi

Try

select  attname, format_type(atttypid, atttypmod),
col_description(attrelid, attnum) from pg_attribute, pg_class c where
c.oid = attrelid
and attnum > 0 and c.relname = 'tablename' ;

Regards
Conni
--
Datenbanklösungen + PostgreSQL + Webdesign
http://www.cornelia-boenigk.de | http://www.pgsql.info
http://www.dpunkt.de/buch/3-89864-175-9.html

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] postgresql field size information

2004-05-27 Thread Scot L. Harris
I need to get the size of the fields defined in a postgresql table for
use in my PHP script.

For instance:

$fieldname = pg_field_name($stat,$i);
$size = pg_field_size($stat,$i);
$type = pg_field_type($stat,$i);

I tried using pg_field_size but for char type fields it returns a -1
indicating the field is variable length.  I need to get the defined size
of the field.  

pg_field_prtlen does not appear to be the correct function to return
this type of information.

I did get most of what I needed from this query:

$stat = pg_query($dbh,"select attname,atttypmod from pg_class c join
pg_attribute a on c.oid = a.attrelid where c.relname = '$tablename' and
a.attnum >= 0");

But the atttypmod field appears to have some overhead included (4
bytes).  I can adjust for that but there must be an easier way to get
the information for a field defined in a table.

Suggestions on how to do this?

-- 
Scot L. Harris <[EMAIL PROTECTED]>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: Informix and PHP

2004-05-27 Thread D. Sandmann
Thought I would post how I finally resolved this problem since it is not
specific to Informix.

The problem had nothing to do with the setup of my environment. It
boiled down to my registries where corrupt. Found many entries in my
registry that had the paths to various files starting with c?\"Some path and
file name".

A number of them where Informix related others where for other
applications\dll's. I downloaded Registrar Lite by Resplendance
(http://www.resplendence.com) and did a global search and replace of all
"C?\" to "C:\" rebooted my machine and everything came up fine.

David

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: Multi search function (help)

2004-05-27 Thread nabil
yes, this is true, we should add empty() function too.

"Ross Honniball" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm not 100% sure, but you may want to also check if the field is empty
> (using empty() function) before including in your search. (in addition to
> isset)
>
> Also, just a caution, you will need to take some care in figuring when and
> where to place your 'and' statements linking the various parts of the
query.
>
> At 08:01 AM 27/05/2004, you wrote:
> >Nabil wrote:
> >
> > > "David Robley" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > >> Nabil wrote:
> > >>
> > >> >  hi all
> > >> >
> > >> > Is there a way to condition your search:
> > >> >
> > >> > -I have a form for four text boxes for search my Mysql...
> > >> > -I don't want to write 4 conditions and for SQL statements incase
he
> > >> > decided not to search with all keywords (fields)
> > >> > - I have by example : name, lastname , nickname and phone  form...
> > >> > I need a way to select my records even one or more field were null
> > >> > (searching only on of the above)
> > >> >
> > >> > because the following SQL will generate null result
> > >> >
> > >> >
> > >> > $name=$_POST['naame'];
> > >> > $lastname=$_POST['lastname'];
> > >> > $nickname=$_POST['nickname'];
> > >> > $m_date=$_POST['m_dateY'];
> > >> > echo $name.$lastname.$nickname.$m_date;
> > >> >
> > >> > "SELECT id, name , lastname , m_date from users
> > >> > where
> > >> > name like binary '%$name%' and lastname like binary '%$lastname%'
and
> > >> > nickname like binary  '%$nickname%' and m_date= YEAR('$m_date')
order
> > > by
> > >> > id ASC ") or die(mysql_error());
> > >> >
> > >> >
> > >> >
> > >> > Thanks in advanced
> > >>
> > >> Use isset to test whether the POST values are set and only include in
the
> > >> query if there is a value.
> >
> > > thanks .. but my question is not for isset... i m thinking consider
that i
> > > have 10 search fields... if i have to do a combination then i need a
day
> > > to right the various SQL statements
> >
> >So do something like:
> >
> >$query = "SELECT id, name , lastname , m_date from users where 1 ";
> >if (isset($_POST['name'])) {
> >   $query .= "AND name like binary '%{$-POST['name']}%' ";
> >}
> >if (isset($_POST['lastname'])) {
> >   $query .= "AND name like binary '%{$_post['lastname']}%' ";
> >}
> >//etc etc
> >$query .= " order by id ASC ";
> >$sql = mysql_query($query) or die(mysql_error());
> >
> >
> >--
> >David Robley
> >
> >Only cosmetologists give make-up exams.
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
> .
> . Ross Honniball. JCU Bookshop Cairns, Qld, Australia.
> .

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php