@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24



Comments:

<0> because something's not working there
<1> You gotta fight! For your right! To poooopy
<2> I guess it is off the ##mysql for me.
<3> Only one #
<4> Joins aren't that bad once you get the hang of the concept
<4> Basic idea is select whatever from table1 JOIN table2 ON table1.id = table2.tabl1_id
<4> That'll probably be about 80-90% of your joins
<5> Okay, name the ONLY single character function
<4> There is one?
<5> Yep
<5> I just got schooled for forgetting it
<4> Think you've gotten too obscure even for me
<5> ((in another channel))
<5> ((where we're laughing at your))
<6> (('Pollita is writing in lisp'))
<4> Heh



<4> Not enough parentheses
<5> Hint: It's not a standard function, but it is in a bundled extension
<4> Hm, don't think I found it, but I may have found a bug in the site's search function
<5> Dragnslcr: Hows that?
<5> hahaha
<7> Pollita: you ever do anything with CamelCase in a wiki before, and, perhaps, know what the regex would be for it? :D
<4> If you search for single-letter function names, some of them bring you to weird pages
<5> ajnewbold: I'm still on the fence wrt wikis
<4> 'y' brings you to the Hyperwave section
<7> Pollita: heh, really?
<5> A LOT of **** brings you to hyperwave
<5> Noone really knows why either
<8> are all $_POST vars strings?
<5> dad: yes
<7> you can't put a bool in $_POST?
<6> ajnewbold: You can
<4> 'q' and 'g' apparently bring you to key()
<6> By nature it only contains strings.
<7> ah
<5> ajnewbold: Ask yourself how that'd look in HTML
<8> Pollita: so, even numerics need to be treated as strings?
<4> 'z' and 'x' go to ssh2
<7> Dragnslcr: best one yet: http://php.net/****
<5> They come to PHP as strings (numeric strings, but strings)
<5> You're welcome to cast them once your script has 'em though
<6> dad: 2954563 == '2954563'
<7> ah I see now
<6> It doesn't really matter.
<9> pollita.. whats is it?
<7> good point
<5> Has everyone given up looking?
<8> kuja, Pollita thanks.
<6> Pollita: What's going on?
<4> Well, if there's a single letter function, the manual search doesn't know about it
<8> Pollita: what are we looking for?
<4> Yes, I did just try all 26 letters
<4> Why I'm doing this instead of going to bed, I have no idea
<6> Pollita: _()
<5> dad: The only function in PHP named with a single character
<5> kuja: very good
<4> Ah, character
<5> http://us2.php.net/manual/en/function.gettext.php
<6> Can't forget gettext
<3> _()?
<6> :)
<6> _() is traditional.
<5> Dragnslcr: I never said 'letter' :)
<3> What's _() do?
<4> Heh, search for '_' and you get to Hyperwave
<6> freeone3000: alias to gettext()
<5> freeone: Hit the link I pasted
<4> Whoever wrote the search function for the online manual must love Hyperwave or something
<5> Dragnslcr: Oh? I'll put that in the translation table then
<6> echo _('This text will be translated!');
<9> ahhh.
<5> Dragnslcr: It's a hisenbug, noone can figure out why it goes there
<4> And whoever decided to make _ a function must really like Perl
<9> its not so bad
<6> Dragnslcr: It's kind of ideal.



<9> because you would type it alot
<6> Dragnslcr: It makes i18n less painful to implement.
<4> Yeah, but if you saw that in code, would you have any idea what it was?
<6> Dragnslcr: Yes
<9> yeah I would .... but I didn't think of it as a function
<6> Dragnslcr: Like I said, gettext is traditional, many languages use _()
<8> kuja: re: $_POST vars as strings - if i have a numeric field in a mysql table, this means i can'
<8> t use the $_POST var directly?
<6> dad: Your PHP datatype is of no concern to MySQL.
<4> You shouldn't be using it directly anyway
<8> Dragnslcr: understood, but if i perpetuate a string datatype, i don't want to be told - 'wrong data type' from a mysql query insert...
<6> $id = '1'; $q = "SELECT username FROM users WHERE user_id = $id"; // The query will be seen as 'SELECT username FROM users WHERE user_id = 1', regardless of $id being a string.
<4> Types aren't actually sent as part of the query
<4> All PHP sends is a single string
<8> kuja: data types are taken care of in the mod_mysql?
<4> PHP's variable types and SQL's field types are completely independent
<6> Heh, no. $q = 'SELECT * FROM table'; // What datatype is $q, dad?
<4> Like I said, all the database sees a single string containing your query
<10> INT!
<4> Object(stdCl***)!
<8> kuja: ok, i'll just validate the data, and submit the query...
<8> kuja: in your example, $q is a string type
<5> http://news.php.net/php.mirrors/30857
<5> There
<6> Yes. What happens when you put a string into a string, dad?
<8> kuja: it's still a string... oic!
<6> dad: Yes :)
<8> kuja: so, there's no way around it...
<6> No way around *what*?
<11> Is it possible to explode('',$string) into an array of hash values (similar to PERL) where the values are what's returned from explode()?
<6> When you tell PHP to send a query to MySQL like: mysql_query('SELECT username FROM users WHERE user_id = 1'); // MySQL doesn't care, it just receives the query as SELECT username FROM users WHERE user_id = 1, so you see, PHP datatypes are *irrelevant*.
<5> EricL: Um....precisely like that....
<6> It's a matter of what MySQL sees.
<8> kuja: no way of changing the data type - it'll be a string when i build the query...
<6> dad: Yes, and what's wrong with that?
<11> Pollita: I thought it returned numeric array values when something like $array = explode(',',$string); is done.
<5> The array values are whatever is in the original string (delimiter excluded)
<8> kuja: nothing, nothing at all. but it does make the job of programming for a database app easier, by not forcing data typedness
<10> night
<11> Pollita: I know the values are that, but I want to be able to reference them by their value, not by their location in the array.
<8> i have worked with languages and databases that were strongly typed, and it seems to me it was always a fight
<5> So let's break this down into an example. Say you start with $string = 'foo,bar,baz'; And you do $arr = whatever($streing
<11> Pollita: Meaning that if $string = "ab,cd,ef"; I want to be able to check for the existence of $array["ef"] as opposed to $array[2]. Can I do that?
<5> Ah.
<5> Yes, but only by applying a second step.
<5> http://us2.php.net/manual/en/function.array-flip.php
<11> That's fine, I would rather do two steps upfront than having to do 6 later on down the road.
<11> Pollita: So to make sure I understand this, $array["ef"] would then have a value of 2 now and $array["ab"] would have a value of 0?
<8> is there a good explanation somewhere of regx, as applied to php?
<5> yes
<5> ((erm, yes to EricL)
<11> Pollita: Is there then a way to set all values (not keys) in that flipped array to 1 (since I just want them all on for when I run them through conditionals)?
<8> EricL: you can search an array for values...
<5> EricL: Well, you could array_walk(), but why do they need to be 1? Because you're going to do: if ($arr['whatever']) { ... } ?
<5> 'cause if that's the case then: if (isset($arr['whatever'])) { ... } would solve that issue easily enough
<11> Pollita: They don't NEED to be 1, there just can't be 1 with a value of less than 1 (ie that first value of 0).
<5> You could also do: $arr = explode(',',",$string"); unset($arr[0]); $arr = array_flip($arr);
<11> Oh yea. I didn't even think of that. (I have been using PERL for the past 2 weeks and I am trying to get back to the PHP mindset and was wondering why defined() wasn't working) :).
<8> EricL: but array indexes start at 0...
<5> Which basicly creates a dummy element 0 which can be tossed out
<5> dad: Not his
<6> EricL: "Perl"
<8> Pollita: oic
<9> I'm gonna take off... nice chatting with you all .. have a good one
<5> EricL: If I understand your usage correctly, you wouldn't even need to unset($arr[0]); as you could just "pretend that $arr[''] doesn't exist" since you never test for it.
<5> But the isset() route is the cleanest for sure
<11> Pollita: Basically, what I am doing is I am pulling a SET out of a MySQL database and exploding it into an array and testing for which values are set.
<5> It's also *faster* that if ($arr['whatever']) { ... } ironically enough
<5> But that's an artifact of isset being a construct, not a function
<5> nod
<11> Since I don't want to do it all with conditionals, I wanted to use the references in an array (which you showed me array_flip) and then I can use isset().
<5> There's a couple other approaches (array_search() for one), but explode/flip/isset is probably the cleanest/quickest
<11> That's what I figured because that's pretty much how I would accomplish it in Perl.
<11> Thanks for the help.


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #php
or
Go to some related logs:

#linux
#fedora
python unexpected end of regular expression
tvtime xvoutput badvalue
gentoo cc1plus pentium-m
#math
locale not supported by xlib locale set to c wine ubuntu
Module snd_ioctl32 not found
ubuntu resolv.conf
#css



Home  |  disclaimer  |  contact  |  submit quotes