« first day (453 days earlier)      last day (4489 days later) » 

4:02 PM
"The Grumpy Programmer's Guide To Building Testable PHP Applications" - looks like an interesting read: http://leanpub.com/grumpy-testing
 
@LeviMorrison Because I really don't like the current layout. At least peek and peekTail aren't good
 
@NikiC Yeah, we did talk about renaming them, or possibly removing them altogether.
 
@LeviMorrison Removing?
@LeviMorrison No, they should stay, but using a different name
@LeviMorrison What I will replace is the ArrayAccess by some functions that operate at the current iteration position
 
that's him, right?
interesting
 
.
how can i start php programming?????
i am just a beginar
 
4:08 PM
@AboobackerMk buy a book
5
 
@NikiC ArrayAccess needs to be implemented, methinks. I really do. I wasn't entirely sure what your statement meant, so I thought I'd make my opinion on that clear.
 
@LeviMorrison Hm, methinks the other way around, that it mustn't be ^^
 
@LeviMorrison @NikiC my former english teacher once asked me in what century i'd live when i used methinks in an exam paper
 
@NikiC Just because the operations are inefficient doesn't mean they shouldn't be there.
I've used a LinkedList as a list plenty of times.
In PHP, that means I'd use ArrayAccess.
 
@LeviMorrison If you need ArrayAccess you don't want to use a LL.
 
4:12 PM
@NikiC That, my friend, is an incorrect assumption.
 
Provigin stuff like insertAfterCurrent etc, yes, but not array access
 
Your statement would be correct if it was "If you need ArrayAccess, you probably don't want to use a LL".
 
@LeviMorrison No, I meant it absolute :D But if you can prove otherwise, I'm always eager to hear ;)
 
Sometimes I have data where I normally am adding to the front. Doing that with a normal array screams inefficient because it has to shift the entire array. On that same data, I sometimes add in the middle. Not usually, only sometimes. So in the overall scope of things LL is more efficient.
 
@LeviMorrison When you add in the middle, where do you know the index from and why can't you do it while iterating?
 
Jon
4:17 PM
If anyone is codeigniter friendly and wants to help me out with a deadline of tomorrow 5pm... will pay monies monies
im screwed otherwise ;)
 
@LeviMorrison Still there?
 
@NikiC Usually it could be done while iterating. But I know that sometimes I've known it while NOT iterating. Maybe I still have the code around and can provide it.
@NikiC Yeah I was trying to find the exact use case. I can't seem to find it.
 
@LeviMorrison I'm still not convinced. Would be really nice if you could find the use case ;)
 
@NikiC I'm sure I have it, I'm just so busy.
Two jobs, university classes, newly married, working on PHP core. . . .
lots to do.
@NikiC Can you move on to some other structure?
HashSet and HashMap, for example?
 
@LeviMorrison I'll just implement it somehow, one can still change later ;)
@LeviMorrison Those will be hard I think.
I mean the implementation will be hard
 
4:23 PM
@NikiC Not really, have you looked at my Set implementation?
 
At least I'm not sure how to do it, especiall for the array case
 
What do you mean, array case? Using an array as a hash?
 
Using arrays as a key ^^
For map I mean ;)
 
Honestly, I don't think it SHOULD be allowed.
Maybe I'm just biased :)
 
@LeviMorrison Well, if we go arbitrary, why not go really arbitrary? Though yes, there could be problems.
Especially as with arrays you have the loose / strict comparison issue
 
4:26 PM
@NikiC PHP's arrays aren't built for it, flat-out.
@NikiC exactly.
 
@LeviMorrison Could there be any use cases for array keys?
 
@NikiC Probably.
 
Well, without arrays it would be fairly easy, yeah
Though we would still need to discuss type semantics
E.g. whether we want true === 1 === "1" === resource(1)
 
4:49 PM
Hi everyone
 
Hi @BenjaminBrizzi
 
I'll probably realise what I'm doing is stupid by typing it out but bear with me
 
hiya @BenjaminBrizzi
 
I have a web service with a Logger class that logs stuff
 
Hi @PeeHaa
 
4:50 PM
@Donut hiya
 
Hey @Donut. Great that you are back! (I mean, as a donut)
 
Except I read somewhere that file I/O is expensive so I decided to store all the logged info in a buffer and write it to disk as the web service returns its data
 
hi @Donut!
 
so i have some $logger->write() in my code and a single $logger->commit() at the end.
 
@BenjaminBrizzi except I read somewhere, a great way to base decisions...
 
4:51 PM
^^
 
@ircmaxell My first thought ... ^^
 
It was somehow ironic
 
Jon
0
Q: PHP to Codeigniter syntax - Subtraction selecting from db / form input

JonI am trying to turn a php mysql statement into Codeigniter syntax. The code selects all from a db but the zone difference equals to two form inputs subtracted from each other. Any help is much appreciated. PHP Version select * from zone_cost where zone_diff = @( (select zone from station_zone w...

many thanks anyone
 
I probably read it in more than one place if I stillr emember it :P
 
@NikiC :-P
 
4:53 PM
Well I guess my question is is it really taxing for a php script to do a dozen file IOs for logging at each call or is it acceptable?
 
@ircmaxell wtf opening your blog in chrome crashes my browser :P
 
@NikiC We need to provide a default comparison, but I think we should allow a user-defined comparison function.
 
@ircmaxell Yeah, I think I already read that somewhere :p
 
@PeeHaa works fine in mine
 
4:54 PM
@NikiC Really? :)
 
@ircmaxell It's not that a really blame your blog, but rather my browser :-)
 
nice
 
@LeviMorrison Could you elaborate on that? How would that look like?
@Donut Yes, you're a good donut :P
 
@NikiC But I'm no more Robik :(
 
@ircmaxell So, what you mean is: 1. I complete my code, 2: I profile it, 3. if logging reammy slows the code, I optimize it.
 
4:58 PM
@BenjaminBrizzi Exactly
only worry about if it's too slow if the application isn't fast enough...
 
@Donut Is Robik your name?
 
@ircmaxell Alright, thanks.
 
@NikiC No
 
 
@ircmaxell Have an upvote, or a star, or something.
 
4:58 PM
óÒ Just found that on reddit
 
@BenjaminBrizzi lol, it's ok. Helping is reward enough
2
 
@NikiC public function compare(Callable $func)
 
@LeviMorrison Not sure that this is really necessary.
 
@NikiC Otherwise they are stuck with our comparison. If we choose ==, someone will complain. If we choose ===, someone will complain.
This way we can choose one but let them change it.
It also lets them define a comparison function specific to their objects.
Since PHP doesn't have the interface Comparable, there isn't much else to do.
 
@LeviMorrison Well, I've not seen anyone about normal array comparisons yet ... and those are loose.
 
5:02 PM
C++ fixes this same problem in a similar manner.
@NikiC I'm not sure what you mean. Your sentence is incomplete.
 
@LeviMorrison I don't understand why we need a way to provide a custom comparison function
 
@NikiC @hakre @ircmaxell Jakob Westhoff
 
(We are still talking Map, right?)
 
@NikiC Map, Set or anything that does comparisons intrinsically.
 
@edorian the () regex thing?
 
5:04 PM
@NikiC The reason is simple: I define my own class Foo. Foos are identified by a property they have, not based on all properties they have. Using == will fail, and so will ===.
 
Yeah. That
 
@edorian @JakobWesthoff You are evil!
 
@edorian I had two, him or Thomas Weinert
 
@hakre It's from a FrosCon workshop they gave together. So you are right too :)
 
@edorian gotcha ;)
 
5:09 PM
hi
I am trying to make SELECT from one DB and INSERT into another DB
And I see ppl do this
SELECT * FROM db1.table
UNION
SELECT * FROM db2.table
UNION
SELECT * FROM db3.table
but when i try that in my code it does not work. is there something that I need to do before I can use this method ?
 
@LeviMorrison I'm still not convinced. I hope you do realize that this would make the implementation pretty slow? If we use normal array behavior + spl_object_hash we could implement Map simply using a normal array internally. But if you want a custom comparison function, I'm not even sure how to implement it at all (efficiently).
 
@NikiC Not being able to define a custom comparison would be a huge deal. I am convinced.
 
@LeviMorrison I don't like you.
 
I really hate
 
@NikiC As far as performance goes, we could log that they have provided a custom comparison function and then use that code, otherwise just use the normal one.
 
5:16 PM
Smarties implementation or the smarty syntax workflow?
 
If I have 2 files and declare a global $var in file 1 and include it in file2, should i be able to access $var in file2?
 
Because I quite like(d) the latter before twig came around
 
@Howdy_McGee If you are use global you're already doing it wrong :-)
 
lol whys that?
 
@Howdy_McGee that's just a saying. Global variables are accessible globally, which includes across file boundaries if both files are part of the same process.
 
5:20 PM
hmmmmm ok
i must be missing something somewhere then just making sure i understood it
 
You can find that in the PHP manual as well, I think it describes it better than I do: de.php.net/manual/en/language.variables.scope.php
 
@Howdy_McGee globals aren't really needed and only make your code hard(er) to debug IMHO
 
@NikiC Can you really not see the value of a comparison function?
 
yeah I agree but i figure if I need only 1 global variable to be used across all my wordpress pages it would make it easier vs an includes
 
@Howdy_McGee what do you mean by all my wordpress pages?
@Howdy_McGee are those separate requests?
 
5:26 PM
im editing a wordpress blog and Im making a global var to hold their location so then I can use it across multiple pages to filter content
and for some reason I was having trouble accessing a normal variable through the includes so I figured I'd go global
 
hmmm
yawn
 
@Howdy_McGee "hold their location" what location? / whos their?
 
the users
the story is I have a bunch of sister websites linking back to 1 blog, depending on what url they are coming from i'm filtering content accordingly
 
@Howdy_McGee aha
 
@HowdyMcGee Can you say database entry?
 
5:31 PM
idk the way I have it set up I don't need to make any database calls other than retrieving posts
 
@Howdy_McGee You're prop looking for a session variable php.net/manual/en/book.session.php
 
^ yeah but they're also coming from entirely different domains
from what I learned yesterday (thanks to here ^.^) Sessions are stored on a servers /tmp folder
once they leave that server the session can't be accessed
so in the end im just adding ?location= at the end of all the blog links
 
@Howdy_McGee once they leave the server you don't have to remember where thet came from right?
 
well if they leave domain1.com and come to domain2.com/blog I need to know they came from domain1.com to filter content
 
so use a session. I.e.
they come from example1.com and go to example2.com/blog
Then you can set a session variable to keep track where they came from across your pages on example2.com
@HowdyMcGee You're not setting the session on example1, but on example2
 
5:37 PM
hi
I am trying to make SELECT from one DB and INSERT into another DB
And I see ppl do this
SELECT * FROM db1.table

SELECT * FROM db2.table

SELECT * FROM db3.table
but when i try that in my code it does not work. is there something that I need to do before I can use this method ?
 
I must not be following :/
ohh
ok i see what your saying
 
@Howdy_McGee :)
 
so then use that session variable to hold the location instead of a global
derp
thats a good idea
:D thank you
 
@Howdy_McGee yup :-)
yw
 
radi you are just selecting,its a right syntax to select all the rows of a table
 
5:46 PM
please! anybody?
@fluty no
notice the db1, db2, db3...
i am trying to unite tables from different databases
 
@LeviMorrison btw, if we already dropped the Doubly, do we want to frop the Linked too? Like C++ did?
 
@NikiC C++ has no Linked List?
 
@ircmaxell No, I'm talking about the name ;)
C++ just called it list
 
40
A: .Net Data structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary -- Speed, memory, and when to use each?

Sam SchutteOff the top of my head: Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion and retriv. speed. ArrayList - automatically growing array. Adds more overhead. Can enum., pro...

 
Which sounds fairly reasonable as that's all lists there is afaik
@ircmaxell Exactly: List :)
 
5:56 PM
Well, but looking at it, it's not a DLL, but an array
> The List: a Homogeneous, Self-Redimensioning Array
 
@ircmaxell in java, .net list means ordered collection
 
which in terms of behavior is identical to a DLL, except that insertions in the middle take up significantly more time in an array, whereas traversing to an index takes significantly more time in a DLL...
 
@ircmaxell cplusplus.com/reference/stl/list That's what I was talking about in the first place ;)
 
if you remember, we had this missinterpretation earlier - I was talking about collection while you were talking about linked list - bloody java :-)
 
@NikiC You can't use List. It's a language construct.
 
5:59 PM
@LeviMorrison done, discussion closed
 
@LeviMorrison Oh, damn.
@LeviMorrison That was an easy solution ^^
 
You think I never thought of that? Really? :)
 
@LeviMorrison Really :)
 
6:15 PM
I think it's coming to time to get a new laptop...
 
@ircmaxell I'm way past that time. Getting married killed the tech budget :)
At least when I do buy a new one I'll get better hardware for my $$$.
 
yeah, I don't have that problem ;-)
$2175 for a new Lenovo configured as I would like it...
 
You don't go light when you get new tech, do you?
 
not at all
hrm, got another down to $2k..
 
When I buy tech, I just buy the cheapest that will meet basic needs.
 
6:24 PM
My laptop that I'm currently using is a 2006 model...
so I go all out, because I know I am going to use it until either it fails, or it becomes unbarable...
 
That's not bad.
In my experience, hardware is what goes bad in laptops. In general we are too hard on laptops, I think.
 
@LeviMorrison Have you ever used a Lenovo/IBM Thinkpad?
 
We have five various Thinkpads here
They're pretty good machines.
T-series.
 
yeah, I have a T61p right now. I tell you, the hardware is bulletproof. I've supported literally dozens of them (salespeople none the less), and the only hardware failure I saw was of a hard drive went belly up...
They aren't the prettiest, and they def aren't the lightest. But they work..
 
@ircmaxell I have used lenovo, yes. I quite like them.
Their prices are reasonable as well.
 
6:38 PM
fairly
 
I wish we could buy more of them. Our other laptops are Acers. While they work well (despite Acer's reputation), they always feel so flimsy.
 
We are getting ready to replace our Dell netbooks at work. I am pushing for Lenovo but our director is unsure. He's an Apple fanboy, but he's not sure he can get Macbook Air approved . . . :)
 
why the heck is it so hard to find a laptop with 1920x1200 resolution in a 15 inch or smaller form factor
 
Yegods, do you have 20/10 vision?
 
@Charles corrected, yes
 
6:43 PM
I know this sounds like a massive hack, but is it possible to fire a function when a certain property is read? (The property does exist, so can't use __get())
 
I'm choosing Lenovo for years, never regretted.
 
My T61p has 1920x1200 in a 15" package, that's why I got it
 
Well that explains that then, but still, yikes.
@Greg Not without the horror that is the magic getter and setter.
 
@Charles I want real-estate. Using even a 168x1050 19" monitor feels really bad
 
Dual screen ftw
 
6:44 PM
@Greg I have 3 of them
 
yeah triple head FTW.
 
three dual screens??
 
@Greg Yeah, but that's not exactly an option in a laptop.
 
No, 3 screens in total...
 
Where I work you can instantly know how important you are by looking at the size and number of screens you have.
 
6:45 PM
a 24" in the center, and a 22" on either side (the left one turned 90* so it's tall)
 
I've been pondering rotating my 19" 1680s vertical instead of horizontal... then again, I'm about 90% sure that X would freak out and die on me if I tried...
 
@ircmaxell sounds like a great setup - I've been playing around with portrait mode, pretty useful but I haven't got into the habbit of using it portrait
 
@LeviMorrison All but like three workstations here have dual monitors, even the guys in the warehouse.
@ircmaxell Hear hear.
 
@Greg Yeah, I keep one monitor (this one that chat is on) vertical, split in 2 vertically with this window on top, and Outlook below it)
 
6:47 PM
Never seen a dock that is able to handle 6 displays.
 
mine handles 2
 
Interesting - I chose to use the portrait monitor for my code, having two files open split horizontally
 
USB video card adapter time!
 
> Use up to six (6) adapters simultaneously with a single computer for multi-display capability
@Greg I do that on the main monitor, with 3 panes for code (2 stacked and one full hegiht)
 
@ircmaxell would be fun to try out, but I only have 2x USB 3.0
 
6:50 PM
@hakre they are USB 2.0 ;-)
 
I wonder if the bandwidth is enough
 
@ircmaxell I don't understand what those are for?
 
For 6 displays
 
@Greg USB to VGA. It's a USB video card
 
oh ... so you can have 6 displays. I read that as you had 6 displays
 
6:51 PM
No, I only have 3
 
It's probably worth to connect multiple ones on the dp port
not the usb port
 
perhaps. If you have dp...
wtf, the 15" macbook pro has only 1440x900 resolution? that's half the number of pixes as my current 15 inch...
 
wait for the release of macbook extra pro .. 2
 
posted on January 12, 2012 by Ulf Wendel

New in the PHP manual: a mysqli quickstart. You are new to PHP but you know how to code, you know SQL, you know relational databases and MySQL? Then, I hope, this is for you. All you need is a quick overview on the concepts? The rest is ...

 
wow
 
6:57 PM
@hakre @Feeds?
 
@Charles Right but what size of monitor? If you are important, you have at least two 30" monitors . . .
 
@LeviMorrison Almost all of them are 6-7 year old 19" non-widescreen LCDs. Only a few have widescreens -- me, the other dev and marketing.
and now, afk
 
@ircmaxell are your monitors IPS/PVA so you can rotate them?
 
I've rotated them and they worked, so not sure what one has to do with the other...
 
@NikiC jup
 
7:02 PM
@hakre agree
 
I was naive when buying my first monitors for work thinking that ordinary monitors can be rotated. The text looked awful when rotated 90 deg, as the monitors were TN display which is what the majority of monitors are.
apparently, pixels on "ordinary" monitors aren't square, so the individual red, green and blues "bleed" from pixel to pixel when rotated
I thought I needed glasses
 
7:21 PM
6
Q: Reaching 100% Code Coverage with PHPUnit

nikc.orgI've been in the process of creating a test suite for a project, and while I realize getting 100% coverage isn't the metric one should strive to, there is a strange bit in the code coverage report to which I would like some clarification. See screenshot: Because the last line of the method b...

> SO question: two days ago => phpunit bug tracker: one day go => bug derick about: it 1 day go => xdebug issue: 1hour ago, fixed: just now
I love open source when it works :P
 
PHP frameworks are sucking nearly as much as PECL and PEAR.
It is fun to watch those numbers.
 
this is more of a php/mysql combo question but... what is the best way to query a database for information like search engine... cross table and cross rows
using mysql for db, php 5.3.6 and codeigniter framework
 
7:37 PM
Eh, I just use site-search from Google . . .
 
yeah problem is im not searching for pages
trying to create a site to search for things about a specific city
 
Man, this is the best question I've ever answered:
6
Q: PHP Card Game: Randomly pick 1 number out of array of 52 with no duplicate?

Tech4WilcoI have a simple card game (using 52 cards - no jokers) that I want to randomly pick 1 card at a time until the wining card is chosen. I have this array: $cards = array( 'diamond' => array( 'A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K' ), 'heart' => array( 'A',...

 
could mean news articles, events, etc.
lol
 
7:51 PM
@Mike Use a real search engine technology. Look into something Lucene based, like, well, Lucene, or Solr, or ElasticSearch
 
or Sphinx
70
A: Find first character that is different between two strings

ircmaxellYou can use a nice property of bitwise XOR (^) to achieve this: Basically, when you xor two strings together, the characters that are the same will become null bytes ("\0"). So if we xor the two strings, we just need to find the position of the first non-null byte using strspn: $position = str...

 
@LeviMorrison You went a little overboard there didn't you? A strange version of overboard though. The JsonSerializable has kinda nothing to do with the rest and the deck constructor is still procedural php :P
 
@edorian yeah, it's rather odd...
good, but odd
 
Its nice to show off a lot of random php features though
Bonus points for the error suppression on mt_rand
 
I'm actually confused on that one. I've never seen mt_rand complain about anything before.
 
8:03 PM
what's it complaining about?
 
Thus my question.
 
Seems like "copy random code from the internet without reading it" syndrome
 
the only thing I can think of is if the range is invalid...
 
> Warning: mt_rand() [function.mt-rand]: max(-1) is smaller than min(0) in /code/G8bleu on line 2
 
>php -r "mt_rand(1, 0);"

Warning: mt_rand(): max(0) is smaller than min(1) in Command line code on line 1


Call Stack:
    0.0001     318040   1. {main}() Command line code:0
    0.0001     318136   2. mt_rand() Command line code:1
lol
but that's not possible in that code
due to the conditions on the for loop
 
8:08 PM
Summary of Reasons to Create a Routine
Here's a summary list of the valid reasons for creating a routine:
• Reduce complexity
• Introduce an intermediate, understandable abstraction
• Avoid duplicate code
• Support subclassing
• Hide sequences
• Hide pointer operations
• Improve portability
• Simplify complicated boolean tests
• Improve performance
In addition, many of the reasons to create a class are also good reasons to create a
routine:
• Isolate complexity
• Hide implementation details
• Limit effects of changes
 
actually, looking at the downvoted answer, that shuffle isn't biased. It's not optimal, but where's the bias?
 
Isn't it biased towards a normal distribution of colors?
 
well, on each iteration, each color has an equal probability of coming out...
which is biased as I think about it...
point redacted
 
Yeah.. ok :)
I like kent becks/UBs (?) list a lot more:
A function is small enough if you can't split it in two functions
 
redacted
 
8:15 PM
The Fisher–Yates shuffle (named after Ronald Fisher and Frank Yates), also known as the Knuth shuffle (after Donald Knuth), is an algorithm for generating a random permutation of a finite set—in plain terms, for randomly shuffling the set. A variant of the Fisher–Yates shuffle, known as Sattolo's algorithm, may be used to generate random cycles of length n instead. Properly implemented, the Fisher–Yates shuffle is unbiased, so that every permutation is equally likely. The modern version of the algorithm is also rather efficient, requiring only time proportional to the number of items bei...
 
I wasn't pointing at the algorithm
but the period size of mt_rand vs 52!
 
I was trying to make it show the bias source disucssion
btw:
 
lol
crap. It's too hot in here, can't think...
 
@edorian How do I feel now? A little retarded.
 
Actually, I was right
@LeviMorrison's version is biased...
meaning that mt_rand is seeded with a 32 bit int.
meaning that there are at most 2^32 possible starting sequences
and given that there's no attempt to utilize the long period, it falls way short of the 2^225.6 possible hands
now, if you computed all of the states from the same seed value, you should be ok considering the large period of the MT algorithm (2^19937)...
 
1
A: Updating the security of stored md5 passwords in PHP

ircmaxellOk, let's go over a few points here What you have in $salt is not a salt. It's deterministic (meaning that there is no randomness in there at all). If you want a salt, use either mcrypt_create_iv($size, MCRYPT_DEV_URANDOM) or some other source of actual random entropy. The point is that it s...

 
Man, I wish they didn't decline the general reference close reason.
 
yeah, I wish there was an RTFM
 
well in that question the user was already using the right function.
I mean if I use the function and I'm not clear, I use the manual.
Probably I do that too often, but however^ ^
 
RTFM
 
9:06 PM
@edorian It went iteration to iteration.
@ircmaxell My version is biased because PHP's shuffle is biased. . . I allow you to provide your own shuffle function.
Although, I'm not sure I implemented the custom-sort correctly.
 
yeah
 
Also, as it went iteration to iteration, I could have made it much more . . . object-oriented by removing strings as suit identifiers. I wasn't sure if that was a good idea. I always try to strike a balance between good and good enough when answering SO questions.
At the time I was sick of noobish, incomplete answers. So I went almost all-out on it :)
It payed off in votes, though.
I see it received a few more today after posting it. Didn't mean for that to happen, but thanks everyone.
 
:-P
 
I have a question for you guys (what else is new :P)
 
0
A: Update old stored md5 passwords in PHP to increase security

TavocadoI looked into this subject a while back and found the following link of great use: Secure hash and salt for PHP passwords I also use the following to create a random salt: public static function getRandomString($length = 20) { $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...

 
9:20 PM
you'll see that the name of the route (user) isn't part of the route itself. This looks strange IMHO. Why is this?
Shouldn't the name (user) be a part of the route?
 
@PeeHaa I don't see what you are seeing, I guess.
 
@PeeHaa Isn't it, though? It's set up to match URLs starting with user/ and then the rest of the pattern, then ensuring those are mapped to the correct controller.
You probably don't want to, say, map the first part (before the first /) to a controller dynamically. While it'd be convenient, it'd also be a potential nightmare for curious users.
s/for/because of/;
 
@Charles @LeviMorrison what I would have done is instead of doing:
$router->addRoute(
    'user',
    new Zend_Controller_Router_Route('user/:username',
                                     array('controller' => 'user',
                                           'action' => 'info'))
);
is doing:
$router->addRoute(
    new Zend_Controller_Router_Route('user', 'user/:username',
                                     array('controller' => 'user',
                                           'action' => 'info'))
);
Where am I thinking wrong about it?
 
So you want the Route Object to actually know its name?
 
Remind me again, what does the second form there do? It's been a while since I worked with ZF's MVC bits.
 
9:36 PM
@hakre Did you vote me again?
 
@LeviMorrison well it might be just me thinking about it the wrong way, but isn't the name part of the route? For example (I'm really bad at coming up with exmaples btw) when you can have persons working on projects. E.g. when you have a person class and a project class. And you want to add a person to a project.
Wouldn't that be like when you have a class Person (Zend_Controller_Router_Route in this case) shouldn't the Person have the name instead of the Projects class ($router)?
@Charles Second form is what I just made up :) The first one is the one that is used. But I think the second one looks more correct, because 'user' is part of the route IMHO.
 
Sorry, I'm still not sure what you're getting at.
 
@Charles I'll try to setup some code 1 sec
@Charles Using the above analogy (people working on a project):
The do this:
class Person
{
    private $name;
    private $age;

    function __construct($name, $age)
    {
        $this->setName($name);
        $this->setAge($age);
    }

    function setName($name)
    {
        $this->name = $name;
    }

    function setAge($age)
    {
        $this->age = $age;
    }
}

class Project
{
    private $people;

    function addPerson($name, Person $person)
    {
        $this->people[$name] = $person;
    }
}
 
@hakre If so, thanks again :D Though the last nine votes went into rep cap :(
 
$project = new Project;
$project->addPerson('peehaa', new Person('27'));
sorry I meant:
class Person
{
    private $age;

    function __construct($age)
    {
        $this->setAge($age);
    }

    function setAge($age)
    {
        $this->age = $age;
    }
}

class Project
{
    private $people;

    function addPerson($name, Person $person)
    {
        $this->people[$name] = $person;
    }
}

$project = new Project()
$project->addPerson('peehaa', new Person(27));
 
9:52 PM
@NikiC Sure, I hate it to not use votes! ;)
 
@Charles But I'm thinking: isn't my name (peehaa) a property of a person?
 
@NikiC hmm, well, good point. Need to look that my votes don't get wasted in the future :D
 
@PeeHaa Only if it makes sense to put the name there.
 
@Charles On what does it depend? The Project class?
 
@hakre stackoverflow.com/questions/7144273/… btw strtr can also do char replacements more efficiently using the two-parameter form ;)
 
9:56 PM
@PeeHaa No, on how you'll use Person.
 
@PeeHaa This seems like a perfect opportunity to use Spl\Map or Spl\Set. Oh wait, they only exist as SplObjectStorage and don't allow scalar values. What a shame.
 
@Charles Could you give a simple example using the same analogy when it does / doesn't make sense to add the name to the person class (if it isn't too much to ask :) )?
@LeviMorrison :P
 
@PeeHaa There's no way I can give you that because I don't understand the full context of the question, and don't understand the use cases of either the Project class or the Person class.
 

« first day (453 days earlier)      last day (4489 days later) »