Re: dizinin eleman sayısı

From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: Mehmet Uysal <mehmath(at)gmail(dot)com>
Cc: pgsql-tr-genel(at)postgresql(dot)org
Subject: Re: dizinin eleman sayısı
Date: 2006-03-27 06:53:41
Message-ID: 20060327065341.GB195@alamut
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-tr-genel

On Mar 26 10:14, Mehmet Uysal wrote:
> Fonksiyonun
> parametrelerini php ile alacağım ve bu dizide null değer olabilir sanırım.

PHP'de dizilerin gösterimi ile SQL dilindeki gösterimleri farklıdır.
Bunun üstesinden gelmek için ise PHP'de bir arayüz fonksiyonu
yazabilirsiniz. Şöyle ki:

function array2sql($arr, $isnumeric=true)
{
$res = "{";

if ($isnumeric)
foreach ($arr as $item)
$res .= $item.",";
else
foreach ($arr as $item)
$res .= "'".IfNeededEscapeIt($item)."',";

$len = strlen($res);
$res[$len-1] = "}"; /* Son virgül yerine } karakteri koyuyoruz. */

return $res;
}

$dizi_int = array(1, 2, 3, 4, 5, 6, 7);
$sql_dizi_int = array2sql($dizi_int);

$dizi_txt = array("abc", "def", "fa'lan", "f\\il'an");
$sql_dizi_txt = array2sql($dizi_txt, false);

... gibi. Umarım yardımcı olmuştur.

İyi çalışmalar.

In response to

Responses

Browse pgsql-tr-genel by date

  From Date Subject
Next Message Mehmet Uysal 2006-03-27 08:32:13 Re: dizinin eleman sayısı
Previous Message murat üngör 2006-03-26 19:45:31 Re: freebsd de postgresql