« first day (874 days earlier)      last day (4065 days later) » 

1:02 PM
hi
 
@NullPointer I'm pretty good. How are you today?
 
1:20 PM
Jon Skeet and Uncle Bob talking about Open/Closed Principle: twitter.com/jonskeet/status/309910791564427264 @Gordon
 
interesting...
and weird...
@PeterStegnar Well, I think I'm okay with SLID - just not the O. I've never liked "single responsibility" == "single reason to change" tho.
 
too bad they wont discuss it on twitter any further
 
yup
 
@andho thanks for the pointer
 
np
 
1:36 PM
I see only 3 potential reasons for a class to change: Adding functionality, fixing functionality (bugs) and refactoring... Are there any others you can think of?
 
I have image caching issue...here is the scenario...I have image header which is like header('Cache-Control: max-age=86400, must-revalidate'); for speed up the page showing images
But when someone upload diffrent image with same name browser shows the old one
And I can't change the name of image as per client requirement
 
why must-revalidate? and why are you overwriting images with the same name? Why not re-name it?
 
@MihaiIorga Re stackoverflow.com/questions/14952157/… - The correct content disposition for a stream like this is inline, not attachment. Also there is no such HTTP header as Content-Transfer-Encoding, HTTP uses to separate headers, Content-Encoding and Transfer-Encoding, and you wouldn't need to use either in that situation
 
weird...
are e-tags properly configured on your server?
(or are you properly using them)?
Or are you sending a proper last-modified date...?
 
sorry no idea about e-tags ?
yes mofied date is proper
header('Cache-Control: max-age=86400, must-revalidate');
header('Content-Length: '.$content_length);
header('Last-Modified: '.$last_modified);
 
1:40 PM
must-revalidate is one of the worst concepts ever designed in HTTP. Just change the URL, forcing a HTTP request every page load to "validate the cache is good" is just as bad as not caching (it saves a few kb of bandwidth, but that's nothing compared to the overhead of the HTTP request...
 
@DaveRandom ok, I will modify ..
 
@Rikesh If you don't know about etags I recommend you go and read w3.org/Protocols/rfc2616/rfc2616-sec13.html - it's a little dry but it is the definitive definition of how HTTP caching is supposed to work and how to use it correctly.
 
@DaveRandom Sure I will
 
Hiya! How do you secure your php files that output stuff for AJAX? I was wondering if I might stumble into some form of race condition if I were to re-use the session. Suppose script1.php generates a page. There, an AJAX request calls script2.php to return some $importantInformation. Obviously, I don't want anybody being able to send parameters there from just anywhere, so ideally I'd like to check if the requesting script is authenticated.
Only one script may operate on a session at any time - so what's the best way to operate here?
 
But I was just thinking that if I just press F5 it shows correct image
 
1:42 PM
@Rikesh More supporting info here as well
 
not even ctrl + F5
So can't I just clear browser cache on some condition
like if uploading image with the same name again
or something
 
@DaveRandom thanks.
 
@ircmaxell That's not what the definition says, although it does seem to be how it is implemented most of the time :-(
 
@DaveRandom in what sense?
 
@ircmaxell In that what it actually says is that you should do that when the cached copy goes stale. And what you can do in that scenario is serve the file again and set a new TTL. But what actually seems to happen is the If-Modified-Since:/304 Not Modified pattern, which is blows the whole concept out of the water.
 
1:46 PM
hrm...
Because a cache MAY be configured to ignore a server's specified expiration time, and because a client request MAY include a max- stale directive (which has a similar effect), the protocol also includes a mechanism for the origin server to require revalidation of a cache entry on any subsequent use. When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to a
subsequent request without first revalidating it with the origin server. (I.e., the cache MUST do an end-to-end revalidation every time, if, b
ok, shower than work... Later
 
@ExternalUse, cookies should be passed on. try setting a header for valid AJAX domains
 
The important point for me, that tells me people do overuse must-revalidate is:
> Servers SHOULD send the must-revalidate directive if and only if failure to revalidate a request on the entity could result in incorrect operation, such as a silently unexecuted financial transaction.
I highly doubt your images are going to result in a linked request becoming non-idempotent (which is what that basically says)
 
@Hiroto -v please? Session cookies are passed on - however, suppose that Ajax Query 1 is still running when another query is fired. The session will be locked.
I could minimise the risk by starting the session, reading authentification and executing session_write_close before actually doing anything. But it feels very dirty.
 
chats messing up today?
 
I have found a relatively good answer to my question, I guess. stackoverflow.com/questions/6262087/…
 
1:59 PM
@DaveRandom If I commented out header('Cache-Control: max-age=86400, must-revalidate'); its works fine
Does it turn off the cache completely ?
 
Pretty much, yes
 
Yeah obv it will
So can't I just control this dynamically
Actually this header code is in one of the global file which handles all images operation on my server
 
Well the problem that you have is that what you want to do is kind of at odds with itself. You want to cache, but you also want instantly to see the new image if it exists. You might get the results you want from max-age=0, must-revalidate but it won't gain you much unless the images are huge or the user/server has a really slow connection
 
I think I should better convince client about that .. That he needs to just refresh that page once :p
After all its a rare case when images have same name I guess so
Thanks for help :)
 
Indeed, although one trick would be to somehow determine when a the file has changed on the server side, and append ?version=x to the image URL in the page, and only change the value of x when a new image version is uploaded
That could be more trouble than its worth to implement though
 
2:08 PM
@DaveRandom - but I don't think than there will be the benefit of cache remains using that trick
As It will send request to server for all the images in the listing table just cause of one
 
@Rikesh No I meant on a per-image basis. Like I say, could be more trouble than its worth to implement
 
Oh ok
 
@DaveRandom why would it be more trouble? That's how I do it so I can have near infinite TTLs on static assets that change somewhat frequently
 
Just last thing if suppose I change max-age to 0 does it mean still cache system is working ?
 
Without googling for the solution: "The barber is a man in town who shaves those and only those men in town who do not shave themselves. Who shaves the barber?"
 
2:13 PM
@ircmaxell Yeh but its non-trivial to implement (and get right) so really its a question of whether the client is prepared to pay for the time it will take
 
@Gordon Well not himself, that's for sure
 
@DaveRandom it's not that difficult...
 
As we had this yesterday, setting the reason phrase and status code: header('HTTP/ 433 Reason Phrase As You Wish');
 
@Gordon he has a beard...
 
@dragon112 but if the barber does not shave himself, then … he must shave himself.
 
2:15 PM
Maybe he has alopecia
 
later
 
@Gordon a deadlock situation :p
 
:This article is about a paradox of self-reference. For an unrelated paradox in the theory of logical conditionals with a similar name, introduced by Lewis Carroll, see the Barbershop paradox. The barber paradox is a puzzle derived from Russell's paradox. It was used by Bertrand Russell himself as an illustration of the paradox, though he attributes it to an unnamed person who suggested it to him. It shows that an apparently plausible scenario is logically impossible. The Paradox Suppose there is a town with just one barber, who is male. In this town, every man keeps himself clean-sha...
 
@Gordon AHHH!!!!! I fell for it!
 
Well sense suggests that the condition is formulated in difference to himself, so the condition does count for all other men but not him.
 
2:18 PM
@hakre that's the suggested solution. you could also introduce multiple barbers or, since we have international women day, women shaving the men :)
 
hello all
 
is it friday already?
 
@hakre I still can't compute it's Friday.
 
2:34 PM
@hakre Don't you rebecca black me!
 
@hakre [insert triple dot here]
 
peace be upon you :)
can anyone help me with inserting json text into mysql problem ?
 
2:50 PM
@AhmedSabry what;s the problem ?
 
morning
 
@NikiC hi !
 
i've a slow loading json text from db and insert it, and the site became slow in loading any another page
 
and why do you insert json code in your db ?
 
@Gordon that Barber paradox got me!
 
2:53 PM
the text inserted but when i opened the page which it getting the json from db then i closed it before it loads the results all pages in the site became slow in loading
sorry for my bad english
did you understand me ?
 
maybe if you could provide some code ?
 
ok just moment
// This the update Function

public function update($json_array, $time, $user_id, $code){
	$json = json_encode($json_array);

	$updateQuery = sprintf("UPDATE tempjson SET json = '%s', date='%s' WHERE user = '%s' AND code='%s'",
								mysql_real_escape_string($json),
								mysql_real_escape_string($time),
								mysql_real_escape_string($user_id),
								mysql_real_escape_string($code)
				);
	@mysql_query($updateQuery);
}
sorry i want to tell you that i'm not facing problem with insert or get
 
spotted one "error"
@mysql_query($updateQuery);
you have to add the connection parameter
$connection = mysql_connect('localhost', 'root', 'password');
mysql_select_db('MyDB'); // ofcourse select a DB
mysql_query($updateQuery, $connection);
 
i'm talking about ( is inserting long json in array will be slow with all servers ? or it slow on my pc as it a computer and not like server in the speed ? )
@HamZaDzCyberDeV i've a public connection, plz read my latest message
 
Some sets are not members of themselves - for example, the set of all red motorcycles - and some sets are - for example, the set of all non-motorcycles. Now what about the set of all sets which are not members of themselves? Is it a member of itself or not? If it is, then it isn't, and if it isn't, then it is... Just like the barber who shaves himself, but mustn't, and therefore doesn't, and so must!
 
3:05 PM
@AhmedSabry Well if it is slow on your PC with just 1 or 2 clients testing, then it would definitely be slow on a server with a large scale of clients
 
@NikiC Morning (UCT)
 
@ircmaxell hey. how's it going?
you survived the internalitis?
 
for now
 
good :)
 
I'm thinking of taking one more swing (not at that directly, but at fixing the problems) prior to hanging up my hat
 
3:11 PM
@HamZaDzCyberDeV it became slow when i refresh the page more than once in same momoent
 
and by taking a swing, it involves drafting an RFC...
 
i wish for more women in tech
hey it's womens day
 
3:27 PM
and women wish for more men in the Catering industry ;)
 
@iroegbu that's not cool
 
Random question... When using namespaces for object classes, is it good practice to use the "use" function (use helpdesk\core\lookup\assignment\AssignmentLookupFactory as AssignmentLookupFactory;) within a class itself or is it probably better practice to place an include file in each class file that defines these aliases...
 
lols... but it's true
the society we have grown in has defined so-and-so jobs to be masculine and others feminine.
smh
 
@iroegbu Not at all. Some people perceive jobs to be masculine and others feminine, but that's not inherant in most people's view points...
the only job I am aware of that's inherantly one way or the other is a wet nurse...
 
@ircmaxell ok... can you imagine a woman working in a construction site... moving concrete... what comes to mind?
 
3:37 PM
imagine? I know some who do that
 
50 years ago it was taboo for a woman to be a police officer... just some perspective.
 
it doesn't seem right... I mean for a woman to carry cement blocks around
 
user895378
7 hours ago, by cryptic ツ
@Gordon we should have Taylor Swift Tuesdays! Who agrees?! =oD
 
user895378
^ No one. No one agrees.
 
Not even Taylor Swift.
 
3:48 PM
I haz made something :) github.com/J7mbo/twitter-api-php
 
user895378
 
@rdlowrey You don't want an [Unsung Hero] then? ;-)
 
user895378
I'd have to get a lot of zero-score answers ... it wouldn't be practical.
 
user895378
I'd rather not drag down my rep:answer ratio.
 
I was lamenting this very thing earlier on
 
user895378
3:51 PM
Thing is, there was a time when I was really close to getting that badge.
 
user895378
I had to have been within one or two accepted answers but then I started getting upvotes on everything and my hopes for were shot to hell.
 
I am currently running (according to data.SE) at 16.6% zero score accepted, with 1374 answers, so it's basically never going to happen for me :-(
 
H @DaveRandom
 
I'm on 11 0 score accepted answers I think, currently at 24% - that's possible for me ^^
 
user895378
Is there somewhere I can see the totals for that without having to manually count them?
 
3:53 PM
:'(
 
Some of my 1374 answers need burninating as well, I need to do a self-audit but I've got better things to do. I tend to edit/delete old answers when they get random upvotes.
Some of them are truly shameful.
@iroegbu Holy crap, what internet connection is that?
 
user895378
Yeah ... makes you wonder which is worse ... the fact that you actually posted that answer or that some moron came along and upvoted it.
 
Looks like 3G
@rdlowrey Probably the latter, as long as I do something to fix (or destroy) the answer when it happens. Still, probably the person who cast the upvote doesn't know why it's crap because they are probably asking the same question
 
I gotta say, I actually am liking Unity...
 
@ircmaxell Nooo!
 
3:58 PM
@DaveRandom DSL
 
I find it totally gets in the way of development - installing gnome classic is significantly better imo
sudo apt-get install gnome-session-fallback Logout and change to Gnome Classic, so much nicer
 
I'm not doing development with it
 
user895378
I've gotten used to Gnome3 at this point ... don't hate it.
 
@Jimbo: I never liked Gnome classic... I was a KDE guy
 
@Gordon Your bit.ly/12qzyU5 in your nomination leads to a 404
 
4:01 PM
No URL shorterners on SO...
 
Odd. The other shortened URLs in his nomination work fine.
Even this one leads to a page, but SO returns a 404 on it
 
@ircmaxell @adamculp I always remove new line characters if my methods get longer than 10 lines. It's so freaking easy! :P
@NikiC: I was going to propose to open a vote to reduce the required majority for the property getters/setters to 50% (to bypass that part of the RFC process). Since it's not a language change we're voting on, that means we only need 50% to pass, therefore we can pass any language change with 50% majority. Hence making 2/3 un-necessary...
but I figured that would be seen (and is) as ridiculous...
 
4:19 PM
Parse Error question
 
Bez
Im looking for a comprehensive resource on domain-driven design, preferably written with PHP in mind. Anyone? :)
 
@RaghavSood @Gordon That's because the Votes tab is not visible to other users, only to yourself and (presumably) mods
 
Bez
Been winging it based on a bunch of articles Ive read, but Im not really confident that Im not doing something really wrong. :( It sucks having to learn it in the middle of the project.
 
than image link would be better idea to show
 
user895378
@Bez IMHO this is THE comprehensive resource on that subject.
 
Bez
4:27 PM
Im up for putting work on hold and read up on DDD.
 
10
A: Domain-driven design with Zend

GordonExcellent question. There is indeed a lack of DDD examples with PHP. There has been a series of articles by Federico Cargnelutti on how to do DDD with PHP and in parts with ZF that might be of interest to you: Domain-Driven Design and MVC Architectures Domain-Driven Design: Data Access Strateg...

 
Bez
@rdlowrey Thanks. Checking it out right now!
 
user895378
If you're not up for paying $48 it's fairly easy to locate on the interwebs for Free-ninety-nine.
 
Bez
@rdlowrey I love the smell and feel of new books so I think Im getting this.
 
-1 for that, I'm all for try before you buy as long as you actually buy ;-)
 
user895378
4:29 PM
@DaveRandom Same.
 
user895378
If something is useful I buy gladly.
 
Bez
If you guys have any other suggestions for software design books, on design patterns, etc etc., please suggest :)
 
user895378
Regardless, that book is definitely useful.
 
user895378
Patterns of Enterprise Application Architecture (Fowler)
Code Complete 2nd Edition (McConnell)
Clean Code (Uncle Bob)
 
Bez
@DaveRandom Thanks for the link.
 
user895378
4:31 PM
Can't go wrong with those three.
 
user895378
I would suggest Code Complete before anything else, though -- it'll change your life.
 
@rdlowrey I found that a little dry to be honest
 
user895378
It's very dry. But indispensable nonetheless.
 
Good, but a little impenetrable. It's just not engaging enough (IMO)
 
user895378
Learning isn't always fun :)
 
user895378
4:33 PM
I tend to agree with you, though.
 
user895378
If you don't want to overwhelm yourself, Clean Code is probably the best place to start. It's very accessible. And Uncle Bob is easy to read.
 
To my great shame, I have yet to read that book. I now own a copy but I haven't had time to sit down and get into reading something for ages :-(
 
Bez
How do you guys deal with team-mates that are just too willing to compromise design for performance?
 
user895378
@DaveRandom Oh dude, it's really easy to read.
 
It lives in my bathroom so I can read it while dropping the kids off at the pool
 
user895378
4:35 PM
As coding books go, anyway. And the chapters are short so you can blow through the book in chunks and feel good about yourself.
 
Bez
Can't fire him, unfortunately. Lol.
 
lol
than through water on mouth
 
user895378
PoEAA is more of a reference IMO. I can't sit down and read it for hours. I'd recommend skimming it and then look up solutions as needed.
 
user895378
@Bez Depends on how important performance is. Sometimes you have no choice.
 
4:38 PM
Seriously though it depends ^^ that
 
Sep 29 '12 at 13:58, by Gordon
@hekko if you want to become an expert programmer, google SOLID, buy GOF, buy POEAA, buy Clean Code, lookup GRASP, DDD, CQRS, DCI … but dont ask for PHP books. That's the most reasonable suggestion I can give you when you ask for Expert PHP books really.
Sep 29 '12 at 13:59, by Gordon
@hekko maybe start here: http://www.ustream.tv/recorded/22783515
@Bez i think its almost all :P
 
@RaghavSood works for me
 
@Gordon and only for you :P
 
@Gordon Yeah I think its because of what @DaveRandom said. That page will probably only be visible to you.
 
Bez
@rdlowrey I do get so too caught up on design sometimes. XD
 
4:40 PM
13 mins ago, by DaveRandom
@RaghavSood @Gordon That's because the Votes tab is not visible to other users, only to yourself and (presumably) mods
 
@Bez design driven design?
 
user895378
@Bez It's okay, I think it happens to anyone who has the requisite amount of O.C.D. needed to be a good programmer :)
 
Nothing wrong with the occasional "f*ck it, that'll do" though IMO
 
user895378
"Good enough"
 
I'd never get anything done otherwise
 
4:41 PM
wow, HUD is pretty cool
 
Bez
Not necessarily DDD.
 
@RaghavSood thanks
 
user895378
Housing and Urban Development?
 
no, Ubuntu Unity's menu navigator...
 
user895378
That's what I think of in relation to HUD.
 
4:42 PM
@Gordon No problem. Good luck with the elections!
 
Bez
I was thrown into a CodeIgniter project after working with Zend for a good number of months. I cringed.
 
@RaghavSood thanks
 
Bez
Not dissing CI in any way, just that it is hugely different from Zend.
 
Mwahaha
 
http://stackoverflow.com/questions/7379524/parse-error-on-line-16
 
4:44 PM
If anyone remembers the guy who was cheat upvoting from earlier
His account = temporarily suspended
 
user895378
Dear PHP: I love you for having array_change_key_case().
 
Bez
Really eager to getting my hands dirty on ZF2.
 
Yep, and my flag was helpful for that :D
 
Ron
whats the best way to find 12 sequential numbers which has the maximum value? for example: for the number 14551115222322251212241225, the answer is 232225121224.
 
user895378
4:48 PM
^ Is that homework?
 
Certainly sounds like it
 
and might from The Open University :P
 
Ron
Not homework, but university exercise
yup, from the open university
 
@Ron I'd say, possibly loop through every number and add to $nums. Once nums hits 12, add them all together and you get a 'high' number.
 
Ron
4:51 PM
It should be most efficient as possible. cant use arrays. only for and if/else
 
Okay, no arrays, screw that.
 
user895378
> And it does not adjust for your time zone.
 
user895378
lol
 
No, it doesn't need arrays actually
So yeah, loop through, once $nums = length 12, add all numbers up, remove the first number then restart loop
 
btw playing with array is really fun
 
4:53 PM
Eventually you'll have a list of numbers, you just find the highest, then err.. figure out how to get that back from the long list of numbers
 
Can anybody help me set up my local PHP development environment? Well maybe a few pointers anyway.
 
@Ron I'm assuming that you mean the sum of the sequential numbers is the result or... what? 12 sequential numbers which has the maximum value is a bit meaningless.
 
@user2143356 on windows install wamp and netbean and you have done
 
Mac
 
Ron
thats what I've done.. want to know if there's better way? such as filtering half of the number or something
 
4:54 PM
Thanks though
 
@DaveRandom I presume from his example that he meant a long list of numbers is given. He has to find the largest sum of 12 of those numbers in a row - returning those 12 numbers
 
screw up mac ...:P
 
@Jimbo Oh I see
 
I'v only ever development onto a live website (well a test domain) - why do I care about doing it locally as I seem to be the only person who doesn't
 
@NikiC LOL
 
Ron
4:55 PM
@DaveRandom yes, like the example I gave:

for the number 14551115222322251212241225
the answer is 232225121224
 
@user2143356 editing speed
 
And with that, it's home time! Have a great weekend all :)
 
any other reasons
 
@Ron Yes I see now
 
@user2143356 while you edit online website it may possible that whole website will down
completely ..
 
4:57 PM
@NullPointer - thanks for advice. I see your point. What about local setup not being quite the same as live setup, e.g. similar to using a simulator to test on mobile devices (client side stuff)
 
@user2143356 you can do by some plugin
 
sorry I don't understand
 
@user2143356 Mozilla web developer tool .. ?
 
Ron
the previous example was wrong. for some reason it didnt copy correctly.
this is the correct example:

number: 14551915228366851806640625
answer: 836685180664
 
I need to get command line access to use Symfony. Is that command line to Apache, PHP or comething else?
 
5:01 PM
@user2143356 well apache php ,mysql and other framwork are same either you install online or offline
 
@Ron think about it. You have (length(string) - length(substring)) possibilities
so to iterate over them is easy...
 
I wont tweet "Happy Woman Day" because doing so is sexism. And hypocritical.
 
@Ron Wait, no vectors allowed?
 
If it hadnt been for the recent stir up in the community I doubt my twitter would be flooded like that today
 
@Ron use a variable called Highest=0, for each from 0 to (length - 12) and set highest if first 12 are higher than highest... before looping back remove 1st character. AFter loop output highest.
 
Ron
5:11 PM
nope. the things which allowed are: basic operators, substring, length (not sure), join, split
and loops ofc
 
?... no for each loops?
 
@Ron Right, so join/split, that's arrays
 
@Ron My example doesn't use arrays anyways. length, foreach, an if statement and a variable.
 
Do I need Composer to use Symfony2?
 
Ron
hmm u r right, dont know why I said they are not allowed
 
5:12 PM
@Ron What from my solution isn't allowed?
 
@Ron You need twelve digits which together form the largest number, or a 12 digit number for which the sum of digits is the largest?
 
@user2143356 Alternatively you could use git submodules.
 
@RaghavSood Per his example it seems to be which sequential 12 digits form the hgihest number
 
Ron
@Bil1 ur answer is valid. I need the most efficient way
 
But then won't 14551915228366851806640625 output 915228366851?
915228366851> 836685180664
 
5:15 PM
@Ron I believe that is the most efficient way unless there is some mathematical magic that can solve this. And how are you measuring efficiency? Ease of code? Memory usage, processor usage, lines processed....
@RaghavSood Ha... good eye. That example is still wrong.
 
WTF. OSX has Safari using 40 days of CPU time over the past week, and it's not even running!!! WTF
 
@ircmaxell Sounds like something apple would do :-/
 
@Bil1 Lol. I'm writing PHP for the first time in 3 years. That's the answer my code gave me, so...
 
Playel @DaveRandom :D
 
Symfony2: can I setup multiple applications/sites with the same code base. It seems not.
 
@Ron Well... If you try to do anything other than loop through and compare you would still be cycling through the given number for "large" digits first (such as 9's) and extracting the 12 digits from their position then comparing those within a loop. This type of solution though would use arrays. It could be more efficient if the given number were thousands of digits but if the given number is 10 or 30 digits then a quick foreach loop like I suggested would be more efficient. IMO.
I have to get back to coding my own stuff here at work though :-P so good luck with it
 
Ron
well in my real problem its 1000 digits..
 
5:29 PM
@webarto ahh beats audio .... sounds like good
 
@NullPointer Accert nothing but the best :D
 
it looks like headphone have beats audio logo :P
 
Super fish
 
@Ron Well, I just wrote a simple one with a for loop that takes less than a second for a 2000+ digit number.
 
to the rescue
:)
 
5:31 PM
Will that work?
 
@Ron It is possible to do it in such a way that you only visit each element once (O(n) in other words), I have just done it but I don't really want to just give you the answer because then I'd be doing your homework for you. But here is a (pretty big) clue: just keep a running total, you don't need to take the complete chunk and sum it on every iteration.
 
@AfnanBashir it's not just a fish. it's a bass!
 
Also I didn't use any arrays, except I kinda did really because a string is just a char array ;-)
 
Wesley Murch is on fire in cv room
 
guys see in c# we can do class declaration with values assignment to variables in single line for ex var x = new { firstName = "john", lastName = "walter" }; and x is of custom type class
can we do something in php that is equivalent to that
`$modelNewCategory = new Category();
$modelNewCategory->place_id = $model->id;
$modelNewCategory->user->id = yii::app()->user->id;`

Can we do this in one line
?
 
5:33 PM
@webarto lol.. you have quick start guide to :P
 
Ron
@DaveRandom I see, thank you
 
@AfnanBashir Sorry, what does that result in then? It looks to me like an object literal, which wouldn't have a class (or it would have the "default class" or whatever)
 
@AfnanBashir You could say (object) array('firstName' => 'john', 'lastName' => 'walter') to get an object if you really wanted one, but frankly, it's not worth it when your arrays are already dictionaries.
 
PLB
@AfnanBashir In c# you create anonymous type, which is used to encapsulate some properties without defining class explicitly (perfect for Linq queries). In php you have defined class "Category" and you assign values to its properties (in another words you do very different thing). If you are asking if php has "syntactic sugar" like: var obj = new MyClass { Property1 = value1, ... } No, it does not.
 
5:46 PM
php's arrays can do pretty much everything you'd need an on-the-fly class for, and don't suck as badly.
 
PLB
@cHao $modelNewCategory is instance of Category that definitely is not stdClass.
 
@PLB $modelNewCategory is not an instance of a class defined on the spot. :P
it's not equivalent to new { property = value } at all
if it'd said new Category { property = value }, maybe
 
PLB
@cHao Yes, I said the same. And since Yii framework is used as far as I remember models actively interact with database, have validation methods, etc, so simply casting array into stdClass all functionality of model will be lost.
 
It could conceivably do like $modelNewCategory->setAttributes(array(...)), though. 2 > 1, but it's still not as annoying as setting each property individually :)
 
@webarto /me still can't work out what that's supposed to mean :S
 
5:57 PM
@DaveRandom Obviously Multmedia Playel that Accerts nothing but the best :P
 
ooh, chat works on my phone
 
yup
 
@webarto Ohhh lol, I totally missed that. Make sure you only use high quality ordio files with it.
 
ordio...
my ocd... nnnghh...
 

« first day (874 days earlier)      last day (4065 days later) »