2009年3月23日星期一

Re: [fw-db] About Quote Escape and StripSlashes

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknHv1UACgkQ7bkAtAithutDDgCgvfOORDDweD//6JMfXCCpOfvn
z2cAoMsWgMnOlNsxLR+LBYr2Ym2rKz5e
=cflT
-----END PGP SIGNATURE-----
apozeus wrote:
> Hi,
>
> I cannot find any information about how to stripslashes / unquote a quoted
> string by Zend.
>
> So assuming we store the data into mySQL:
>
> $string = $db->quote("people's");
>
> $data = array("data" => $string);
>
> $db->insert('database', $data);
>
>
> When i try to retrieve the records using:
>
> $query = $db->select()
> ->from('database')
> ->limit(1);
>
> $results = $db->fetchRow($query);
>
> $returnString = $results['data'];
>
>
> I will get the following string instead:
>
> people\'s
>
> Can anybody enlighten me on how can i unquote a database string in this
> scenario? Is there any Zend method to do the job? Or do i have to use
> stripslashes?
>
> Thank you so much!
>
>

You are double quoting the data. Once manually with quote() and again
when you pass the array to insert. If you don't do the manual quote, you
should be fine.

--

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/

没有评论: