<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://blog.dynom.nl/feeds/atom.xml" rel="self" title="D-talk" type="application/atom+xml" />
    <link href="http://blog.dynom.nl/"                        rel="alternate"    title="D-talk" type="text/html" />
    <link href="http://blog.dynom.nl/rss.php?version=2.0"     rel="alternate"    title="D-talk" type="application/rss+xml" />
    <title type="html">D-talk</title>
    <subtitle type="html">The little things that pop into mind</subtitle>
    
    <id>http://blog.dynom.nl/</id>
    <updated>2011-06-29T06:38:41Z</updated>
    <generator uri="http://www.s9y.org/" version="1.2-beta4">Serendipity 1.2-beta4 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>

    <entry>
        <link href="http://blog.dynom.nl/archives/A-world-without-cookies_20110627_62.html" rel="alternate" title="A world without cookies" />
        <author>
            <name>Mark van der Velden</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2011-06-27T20:00:00Z</published>
        <updated>2011-06-29T06:38:41Z</updated>
        <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=62</wfw:comment>
    
        <slash:comments>8</slash:comments>
        <wfw:commentRss>http://blog.dynom.nl/rss.php?version=atom1.0&amp;type=comments&amp;cid=62</wfw:commentRss>
    
            <category scheme="http://blog.dynom.nl/categories/PlanetPHP_8" label="PlanetPHP" term="PlanetPHP" />
    
        <id>http://blog.dynom.nl/archives/guid_20110627_62.html</id>
        <title type="html">A world without cookies</title>
        <content type="xhtml" xml:base="http://blog.dynom.nl/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>Imagine a world wide web without cookies. And this might not be the strangest thing, since the use of cookies is severely limited since&#160;Wednesday&#160;the 22nd of June 2011 in the Netherlands. And more countries will follow:&#160;<a onclick="javascript: pageTracker._trackPageview('/extlink/www.bbc.co.uk/news/technology-12668552');"  href="http://www.bbc.co.uk/news/technology-12668552">http://www.bbc.co.uk/news/technology-12668552</a>.&#160;</p><h2>The Law&#160;</h2><p>The (Dutch) law, that requires a user to agree before storing data, doesn't only apply on HTTP cookies. But in fact any kind of data that is stored on the users computer. Such as; HTML5 storage, flash cookies. But also desktop applications,&#160;etc.. The law also states that cookies "required" for certain functionality, are allowed without confirmation. Personally I don't see how anything will change, with this exception in place. And I wonder how many experts were involved into making this law. But that is a subject for another article perhaps...</p><h2>What are cookies</h2><p>Cookies are little packages of information stored in the browser of a website visitor, they can contain "small" amounts of data such as an identifiable&#160;token or a user preference.</p><h2>What purpose do cookies serve</h2><p>Cookies are very generic and can be used for many things, good and bad. The most popular probably being tracking your activity and advertisement. But they are also used to keep a state between requests and to store a preference. Such as "remember me" at a login form, or perhaps "no I do not want to participate in your survey".</p><h2>Cookie problems</h2><p><strike>If </strike>When the law becomes international, you are potentially violating laws by simply calling something like: <font class="Apple-style-span" face="'courier new', courier">setcookie()</font> without the users&#160;consent. There are hacks around the typical HTTP cookies, by using flash cookies for example (Oh and btw, here a guide on how to clear those:&#160;<a onclick="javascript: pageTracker._trackPageview('/extlink/www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html');"  mce_href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html" href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html">http://www.macromedia.com/...ngs_manager07.html</a>). And possibly HTML5 storage could play a role here (or any of it's derivatives).</p><p>Another thing that has been happening, is visitor awareness and thus browser features. More and more people block cookies to stop advertisement tracking, but unfortunately this also prevents a user to use the features he or she wants to use (such as login sessions, etc.). There is an answer for this and quite a few browser vendor's plan on implementing the "Do Not Track" (<a onclick="javascript: pageTracker._trackPageview('/extlink/donottrack.us/');"  href="http://donottrack.us/">http://donottrack.us/</a>)&#160;feature, or have already done so. But I'm not too happy with it. The downside of "Do Not Track" is that it's voluntary for website owners and advertisement companies to respect this feature.&#160;Other tools include projects such as "Ad Blocker", that only block cookies (and more) for advertisement purposes. It works pretty good, but that is hardly user-friendly.</p><p>But, back to "no more cookies"... How do you solve the problem of keeping a state between requests over a stateless protocol?</p><h2>Some ideas&#160;</h2><div style="background-color: rgb(255, 255, 255); "><p style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; ">Well in short, I have some ideas but definitely no real answers. I don't think there is a real answer just yet.</p><p style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; ">Let's take the example of a login session. Where you want to offer a secure section to your visitors, where they can (e.g.) read their e-mail, privately.&#160;A few things come to mind:</p><p style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; "></p><ol><li>Identifying yourself in every relevant request, using headers for example or an argument&#160;<font class="Apple-style-span" face="'courier new', courier">&amp;userId=42</font>&#160;in the request. This however has some big problems on its own.</li><li>Digest authentication on every relevant request.</li><li>Take a look at other technologies, such as IPv6 and move authentication to a lower level.</li><li>Perhaps use a commit and rollback system. Where you can do a variety of actions and only your password will be asked in the end, either applying or discarding your actions. Requiring you only to enter your login once. Not the most ideal solution for e-mail though, I have to admit. With this system you would re-post your data to next screens in a similar fashion as e.g. a wizard.</li><li>Or perhaps we need to move away from complete server-side applications and move to the client, Javascript applications and use the HTTP spec a little better as it was intended and only have web-services.</li></ol><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; ">Many, if not all, of the things I mentioned above would require secure connections (SSL/TLS) to avoid other security problems. Which might not be a bad move anyway.</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; "><br /></div><div>Personally I think that there is a future, in an improved implementation of digest authentication over SSL. One that uses HMAC and stronger&#160;algorithms, SSL would then supply the missing server validation feature. It should also be more strict and not fall back to insecure legacy features.</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; "><br /></div><h2>Conclusion</h2><div>All in all I firmly&#160;believe&#160;that the browser should play a big role in this new cookie recipe and should (partially) solve these problems. Also there should be a more clear separation between "generic storage" and authentication versus a simulated&#160;persistency. In more perfect world I would vote for a solution that works on other (underlying)&#160;layers and make it application agnostic.</div><div>&#160;</div><div>I suppose the point I'm trying to make with this article is the following:&#160;Take away a feature the entire world uses (since 1996), and wait for the brilliant and creative minds, perhaps such as yourself, to come up with a more innovative feature. It's time for something better!</div><div>&#160;</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; background-color: rgb(255, 255, 255); "><p>Another interesting read:</p><p>&#160;</p><ul><li><a onclick="javascript: pageTracker._trackPageview('/extlink/www.vsecurity.com/download/papers/WeaningTheWebOffOfSessionCookies.pdf');"  href="http://www.vsecurity.com/download/papers/WeaningTheWebOffOfSessionCookies.pdf">http://www.vsecurity.com/download/papers/WeaningTheWebOffOfSessionCookies.pdf</a>&#160;</li></ul><p>&#160;</p></div><div>&#160;</div><div><i><b>I made some updates to this article, based on some comments.</b></i></div></div> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://blog.dynom.nl/archives/PHP-Quiz-part-4_20101102_51.html" rel="alternate" title="PHP Quiz part 4" />
        <author>
            <name>Mark van der Velden</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2010-11-02T08:18:00Z</published>
        <updated>2010-11-08T09:06:00Z</updated>
        <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=51</wfw:comment>
    
        <slash:comments>5</slash:comments>
        <wfw:commentRss>http://blog.dynom.nl/rss.php?version=atom1.0&amp;type=comments&amp;cid=51</wfw:commentRss>
    
            <category scheme="http://blog.dynom.nl/categories/PHP_1" label="PHP" term="PHP" />
            <category scheme="http://blog.dynom.nl/categories/PHPQuiz_12" label="PHPQuiz" term="PHPQuiz" />
            <category scheme="http://blog.dynom.nl/categories/PlanetPHP_8" label="PlanetPHP" term="PlanetPHP" />
    
        <id>http://blog.dynom.nl/archives/guid_20101102_51.html</id>
        <title type="html">PHP Quiz part 4</title>
        <content type="xhtml" xml:base="http://blog.dynom.nl/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>It has been a while, but here is part 4 of the PHP Quiz series! A few questions to crack your brain about, or perhaps you know them all? Try them and find out! Also do read the idea behind these quizzes, here: <a href="http://blog.dynom.nl/archives/The-PHP-Quiz-series_20090925_46.html" title="The PHP Quiz series - background information" target="_blank" mce_href="/archives/The-PHP-Quiz-series_20090925_46.html">The PHP Quiz series</a><br /></p><p>As always, think of the answer before you execute the code or look it up. <a onclick="javascript: pageTracker._trackPageview('/extlink/codepad.org/');"  href="http://codepad.org/" mce_href="http://codepad.org/">Codepad</a> might help you run the examples. You can find round three <a href="http://blog.dynom.nl/archives/PHP-Quiz-part-3_20090921_37.html" mce_href="http://blog.dynom.nl/archives/PHP-Quiz-part-3_20090921_37.html">here</a>.</p><p>&#160;</p><h2>Visibility is key</h2><p>Now you see me, now you don't<div class="php" style="text-align: left"><span style="color: #000000; font-weight: bold;">class</span> testClass <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #ff0000">$fubar</span> = <span style="color: #ff0000;">"rabuf"</span>;<br /><br />&#160; &#160; <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$test</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/var_dump');"  href="http://www.php.net/var_dump"><span style="color: #000066;">var_dump</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$test</span>-&gt;fubar<span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> dummy <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$test</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/var_dump');"  href="http://www.php.net/var_dump"><span style="color: #000066;">var_dump</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$test</span>-&gt;fubar<span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #ff0000">$object1</span> = <span style="color: #000000; font-weight: bold;">new</span> testClass;<br /><span style="color: #ff0000">$object2</span> = <span style="color: #000000; font-weight: bold;">new</span> testClass;<br /><span style="color: #ff0000">$dummy</span> = <span style="color: #000000; font-weight: bold;">new</span> dummy;<br /><br /><span style="color: #ff0000">$object1</span>-&gt;test<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$object1</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Can $object1 see the private property of object1 ?</span><br /><span style="color: #ff0000">$object1</span>-&gt;test<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$object2</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Can $object1 see the private property of object2 ?</span><br /><span style="color: #ff0000">$dummy</span>-&gt;test<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$object1</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Can $dummy see the private property of object1 ?</span><br />&#160;</div></p><p>&#160;</p><h2>Static, sticky, icky</h2><p><div class="php" style="text-align: left"><span style="color: #000000; font-weight: bold;">class</span> test <span style="color: #66cc66;">&#123;</span><br />&#160; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #ff0000">$counter</span> = -<span style="color: #cc66cc;">1</span>;<br /><br />&#160; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> increment<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/static');"  href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #ff0000">$cnt</span> = <span style="color: #cc66cc;">0</span>;<br />&#160; &#160; <span style="color: #ff0000">$this</span>-&gt;counter = ++<span style="color: #ff0000">$cnt</span>;<br />&#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$this</span>;<br />&#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #ff0000">$object1</span> = <span style="color: #000000; font-weight: bold;">new</span> test;<br /><span style="color: #ff0000">$object1</span>-&gt;increment<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-&gt;increment<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #ff0000">$object2</span> = <span style="color: #000000; font-weight: bold;">new</span> test;<br /><br /><span style="color: #808080; font-style: italic;">// What will the output be</span><br /><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$object2</span>-&gt;increment<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-&gt;counter;</div></p><p>&#160;</p><h2>Getting the class</h2><p><div class="php" style="text-align: left"><span style="color: #000000; font-weight: bold;">class</span> b <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <span style="color: #000000; font-weight: bold;">function</span> getClassA<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/get_class');"  href="http://www.php.net/get_class"><span style="color: #000066;">get_class</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$this</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #000000; font-weight: bold;">function</span> getClassB<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/get_class');"  href="http://www.php.net/get_class"><span style="color: #000066;">get_class</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #000000; font-weight: bold;">function</span> getClassC<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #000000; font-weight: bold;">__CLASS__</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> a <span style="color: #000000; font-weight: bold;">extends</span> b <span style="color: #66cc66;">&#123;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #ff0000">$a</span> = <span style="color: #000000; font-weight: bold;">new</span> a; <br /><br /><span style="color: #808080; font-style: italic;">// What will be returned, 'a' or 'b' ?</span><br /><span style="color: #ff0000">$a</span>-&gt;getClassA<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #ff0000">$a</span>-&gt;getClassB<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #ff0000">$a</span>-&gt;getClassC<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></p><p>&#160;</p><h2>The strptime function</h2><p><div class="php" style="text-align: left"><span style="color: #ff0000">$result</span> = strptime<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2010-11-28'</span>, <span style="color: #ff0000;">'%Y-%m-%d'</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #808080; font-style: italic;">// What is the output?</span><br /><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$result</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'tm_mday'</span><span style="color: #66cc66;">&#93;</span> .<span style="color: #ff0000;">'-'</span>. <span style="color: #ff0000">$result</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'tm_mon'</span><span style="color: #66cc66;">&#93;</span> .<span style="color: #ff0000;">'-'</span>. <span style="color: #ff0000">$result</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'tm_year'</span><span style="color: #66cc66;">&#93;</span>;<br />&#160;</div></p><p>&#160;</p><h2>The oldtimer</h2><p><div class="php" style="text-align: left"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$i</span> = <span style="color: #cc66cc;">0</span>, <span style="color: #ff0000">$loop</span> = <span style="color: #cc66cc;">10</span>, <span style="color: #ff0000">$a</span> = <span style="color: #cc66cc;">10</span>; <span style="color: #ff0000">$i</span> &lt; <span style="color: #ff0000">$loop</span>; ++<span style="color: #ff0000">$i</span>, <span style="color: #ff0000">$a</span> = <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; ++<span style="color: #ff0000">$a</span>;<br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #808080; font-style: italic;">// What is the output ?</span><br /><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$a</span>;</div></p> 
            </div>
        </content>
        <dc:subject>php</dc:subject>
<dc:subject>php quiz</dc:subject>
<dc:subject>phpquiz</dc:subject>
<dc:subject>planetphp</dc:subject>
<dc:subject>static</dc:subject>
<dc:subject>visibility</dc:subject>

    </entry>
    <entry>
        <link href="http://blog.dynom.nl/archives/What-do-you-get-when-you-mix;-MSSQL,-PDO-and-uniqueidentifier_20100608_57.html" rel="alternate" title="What do you get when you mix; MSSQL, PDO and uniqueidentifier?" />
        <author>
            <name>Mark van der Velden</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2010-06-08T19:58:00Z</published>
        <updated>2010-11-02T09:47:31Z</updated>
        <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=57</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://blog.dynom.nl/rss.php?version=atom1.0&amp;type=comments&amp;cid=57</wfw:commentRss>
    
            <category scheme="http://blog.dynom.nl/categories/PHP_1" label="PHP" term="PHP" />
            <category scheme="http://blog.dynom.nl/categories/PlanetPHP_8" label="PlanetPHP" term="PlanetPHP" />
    
        <id>http://blog.dynom.nl/archives/guid_20100608_57.html</id>
        <title type="html">What do you get when you mix; MSSQL, PDO and uniqueidentifier?</title>
        <content type="xhtml" xml:base="http://blog.dynom.nl/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>You get NULL!</p><p>Well you get NULL when you don't cast. Say for example you do the following:<div class="php" style="text-align: left"><span style="color: #ff0000">$dbh</span> = <span style="color: #000000; font-weight: bold;">new</span> PDO<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>..<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #ff0000">$stmt</span> = <span style="color: #ff0000">$dbh</span>-&gt;prepare<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SELECT accountid FROM dbo.Account'</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #ff0000">$stmt</span>-&gt;execute<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$stmt</span>-&gt;fetchColumn<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// NULL</span><br />&#160;</div>
</p><p>But when you do the following:<div class="php" style="text-align: left"><br /><span style="color: #ff0000">$stmt</span> = <span style="color: #ff0000">$dbh</span>-&gt;prepare<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SELECT CAST(accountid AS varchar(36)) accountid FROM dbo.Account'</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #ff0000">$stmt</span>-&gt;execute<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/echo');"  href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$stmt</span>-&gt;fetchColumn<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// &quot;F05C92A1-3119-4206-A123-49A759AC99FB&quot;</span><br /><br />&#160;</div></p><p>I didn't think the casting would be necessary, since according to the manual: <a onclick="javascript: pageTracker._trackPageview('/extlink/msdn.microsoft.com/en-us/library/aa226054%28SQL.80%29.aspx');"  href="http://msdn.microsoft.com/en-us/library/aa226054%28SQL.80%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa226054%28SQL.80%29.aspx">http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx</a> the datatype 'uniqueidentifier' has implicit casts with multiple data-types. But I guess it's just one of those things...<br /></p> 
            </div>
        </content>
        <dc:subject>cast</dc:subject>
<dc:subject>mssql</dc:subject>
<dc:subject>pdo</dc:subject>
<dc:subject>php</dc:subject>
<dc:subject>planetphp</dc:subject>
<dc:subject>uniqueidentifier</dc:subject>

    </entry>
    <entry>
        <link href="http://blog.dynom.nl/archives/Forms,-buttons-and-prototypeJSs-getInputs_20101019_60.html" rel="alternate" title="Forms, buttons and prototypeJS's getInputs()" />
        <author>
            <name>Mark van der Velden</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2010-10-19T10:36:00Z</published>
        <updated>2010-10-19T11:22:55Z</updated>
        <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=60</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.dynom.nl/rss.php?version=atom1.0&amp;type=comments&amp;cid=60</wfw:commentRss>
    
            <category scheme="http://blog.dynom.nl/categories/Javascript_10" label="Javascript" term="Javascript" />
    
        <id>http://blog.dynom.nl/archives/guid_20101019_60.html</id>
        <title type="html">Forms, buttons and prototypeJS's getInputs()</title>
        <content type="xhtml" xml:base="http://blog.dynom.nl/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>In forms you use input elements to send your form. But you can also use "button" elements to achieve the same goal. Quite recently someone committed changes into a framework I use often and changed the "input" elements to "button" elements. Normally this is no problem, but in this case it broke some Javascript I had going on. <br /></p><p>I used to use the following:</p><p><div class="javascript" style="text-align: left">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'myForm'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getInputs</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'submit'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>button<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; <span style="color: #009900; font-style: italic;">// .. </span><br /><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></p><p>But with this function you don't get any "button" elements, to solve this situation I changed it to:</p><p><div class="javascript" style="text-align: left">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'myForm'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">select</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'button'</span>, <span style="color: #3366CC;">'input[type=submit]'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>button<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; <span style="color: #009900; font-style: italic;">// .. </span><br /><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></p><p>It works fine however simply filtering on 'button' might be too greedy and some tweaking might be required. I use this to to track down which button was pressed by the user and act accordingly (e.g. "Save and close" versus "save"). <br /></p> 
            </div>
        </content>
        <dc:subject>buttons</dc:subject>
<dc:subject>form</dc:subject>
<dc:subject>javascript</dc:subject>
<dc:subject>prototypejs</dc:subject>

    </entry>

</feed>
