Re: PHP array to PlPgSQL arrat. How to?

Поиск
Список
Период
Сортировка
От Andre Lopes
Тема Re: PHP array to PlPgSQL arrat. How to?
Дата
Msg-id AANLkTi=AK0yMZwVD01-GoUJvDcXQ0iPECt1w9KoJ3kcT@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PHP array to PlPgSQL arrat. How to?  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
Hi Pavel,

Thanks for the reply. It was exactly that that I'm looking for.

Best Regards,



On Sun, Mar 6, 2011 at 3:05 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Hello
>
> look on array_lower and array_upper functions
>
> http://www.postgresql.org/docs/8.2/static/functions-array.html
>
> for one dimensional arrays - select array_upper(var,1) - array_lower(var,1)
>
> Regards
>
> Pavel Stehule
>
> 2011/3/6 Andre Lopes <lopes80andre@gmail.com>:
>> Hi,
>>
>> Just another question about this subject.
>>
>> It is possible to compare if these 3 PlpgSQL arrays have the same
>> number of elements? How to get the number of elements of an PLpgSQL
>> array?
>>
>> NOTICE:  file types: {image,image,image,image,image}
>> NOTICE:  file details: {type,width,height,html_width_height,mime}
>> NOTICE:  values: {jpg,343,515,"width=\"343\" height=\"515\"",image/jpeg}
>>
>> Best Regards,
>>
>>
>>
>>
>>
>>
>> On Sat, Mar 5, 2011 at 10:44 PM, John R Pierce <pierce@hogranch.com> wrote:
>>> On 03/05/11 11:22 AM, Andre Lopes wrote:
>>>>
>>>> Hi,
>>>>
>>>> I need to transform an PHP array to an PlPgSQL array. The PHP array is
>>>> like this:
>>>
>>> in a relational database, it would be far better to store that sort of thing
>>> as a table, so you can use relational operations on it.
>>>
>>> your example structure would fit nicely into a table like...
>>>
>>> CREATE TABLE images (
>>>    id integer primary key,
>>>    base64 text,
>>>    image_type text,
>>>    width integer,
>>>    height integer,
>>>    mime text );
>>>
>>> and use a view to construct the html_width_height value as it contains
>>> redundant data
>>>
>>> CREATE VIEW images_html (id, html_width_height)
>>>    as select id, 'width="'||cast(width as text)||'" height="'||cast(height
>>> as text)||'"' from images;
>>>
>>>
>>>
>>>
>>> btw, if that base64 field is in fact the binary image, I would instead
>>> change that to `image bytea` and store the image in binary.
>>>
>>>
>>>
>>>
>>> --
>>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-general
>>>
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>>
>

В списке pgsql-general по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: PHP array to PlPgSQL arrat. How to?
Следующее
От: Cia Watson
Дата:
Сообщение: Re: School teacher in need of HELP