logs archiveIRC Archive / Freenode / #php / 2015 / September / 26 / 1
OnceMe
hello, how can I show message after I commit transaction?
Because now, it seems I get random rollbacks, after some insertions are being made and I echo message before I commit transaction
which is false, I need a way to show message only when transaction is commited.
Bruce_dev
If I want to create an engine so I can reuse it in the future, should I stay away from frameworks like Laravel and do it all from scratch?
Or would it be fine to use Laravel
Alphos
OnceMe : $pdo->commit(); echo "foo"; // ?
OnceMe
Alphos:can I return, instead of echo?
Alphos
Bruce_dev people who have written frameworks have thought of things you haven't, have covered them better then you will, and offer periodic patches to bugs and security issues
OnceMe sure, why not ? but once you return, execution stops on the current scope
Bad_Advice_Cat
HAI!!
Bruce_dev
Alright, so using Laravel will be fine Phew
Alphos
Bruce_dev quite frankly no
Bruce_dev
damn
         

Alphos
for engines, you need industrial design software
Bruce_dev
Please explain
Bad_Advice_Cat
(Which is not a bad thing, OnceMe)
Alphos
php can't run cars ! :p
seriously though, what kind of engine are we talking about ?
OnceMe
Alphos:so if($signed_up) { insert into members.... return "logged_in"; $pdo->commit(); }
?
Bruce_dev
Alright, an example: http://tribalwars.net
Alphos
OnceMe no, anything after a commit is not executed
Bruce_dev
if I were to create a game something like that
I would want to reuse the engine/code for future games
OnceMe
because I see in mysql log some weird rollbacks
and its simple php logic
$pdo->commit(); echo "foo"; // ?
so how come echo is executed after commit() ?
Alphos
Bruce_dev : there are free reverse-engineered copies for a bunch of games by that company...
some of them php, some python, some a mix with perl...
Bruce_dev
I know but I'd like to code it myself for experience and such.
OnceMe
whats the correct way to do this?
Alphos
Bruce_dev for real-time games, avoid php, look up websockets, and use something more appropriate like node
OnceMe $pdo->commit(); return "foo";
Bruce_dev
I see
node.js ?
Alphos
yup
likely to scale easier than php, since it won't rely on request-response http cycles
OnceMe
I have something like this: here http://pastebin.com/cQuq1kha
Alphos
a ping every thirty seconds is less cpu-consuming than an http request every thirty second
Bruce_dev
Pretty sure their games are coded in php, but I see what you are saying.
Alphos
OnceMe "stuff after return is NOT executed"
OnceMe
so return will executed after commit() ?
ah I think I f'd it up with return
Ill just use echo
         

Bruce_dev
http://socket.io/ this what you mean for websockets?
Alphos
Bruce_dev : also C#, angular, java... i wouldn't stake my life on it being coded in php exclusively
OnceMe
because it will always rollback
as I return
Alphos
for instance, yes
Bruce_dev
Hmm, interesting. I've got a lot to learn. Are alot of websites hybrid coding like that?
Why would some use php, some java, some angular, etc instead of all one?
Alphos
OnceMe if you don't commit your transaction, it will be rolled back, yes. and if you return before the commit, the commit WON'T BE EXECUTED
Bruce_dev
if php is bad since it can only do http requests, why use php at all then?
OnceMe
yap got it
Bruce_dev
http requests vs ping
I mean
Alphos
Bruce_dev : usually they use languages more suited to the task at hand
Bruce_dev
I see. I've got a lot to learn.
Alphos
so their windows app could be C#, their ios could be objC, their android a subset of java, their backend could be php, their frontend could be nodeJS with some angular for the UI..
Bruce_dev
So your suggestions are, learn design patterns if I plan to make an engine for myself. Learn web sockets (sockets.io?) learn node.js
Alphos
learn to recognize the proper tool for the task at hand
Bruce_dev
Oh, I thought node.js was backend
Alphos
not really, no
Bruce_dev
If they are using java for android though, why not use java for backend as well?
or am I confused.
Sorry man if I'm being too noobie I can ask elsewhere, I see your helping somebody else as well.
Alphos
it could be, but it's really something for frontends, with C10k reached without a problem, the ability to run 2-way websockets with clients (including but not limited to browsers)
Bruce_dev
sorry, c10K?
ill google that one sec.
Alphos
because java backend would mean they'd need a java machine to run their backend, and a java machine is expensive. besides, if they used the android subset of java, they'd have to use tablets for their backend, and trust me, you don't want that
Bruce_dev
Hahahaha
I forgot that android uses a different type of java
Alphos
C10k means 10k simultaneous connections, in the case of node they're even concurrent
Bruce_dev
I see I see.
Well man, I will start looking into how web sockets work, I'm assuming theres a bunch of different frameworks for them? Will I mostly see them in javascript, angular, or is it a node.js thing only?
I appreciate the help
Alphos
it's a standard, it could be implemented in theoretically any language
Bruce_dev
but php uses http requests?
Alphos
but since they allow events to be triggered across them, they're really useful with languages that actually care about events, and javascript is nowhere near as bad as php at that
in theory, php could handle websockets. but it was really built around the concept of HTTP requests/responses
Bruce_dev
I see, so basically as of now php would be slower, isn't optimized/created for such websockets, but could be in the future?
well maybe not "slower" but, use more CPU and all that?
Arnas
hi
Alphos
Bruce_dev : slower yes, not suited for events, not optimized, and probably won't in the foreseeable future
Arnas
http://pastebin.com/2CdQTaVw if I put die(); before $recipe, it dies without any error, but if I put it after $recipe, I get MySQL error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 138" Any ideas why? I can't find any syntax errors :(
Bruce_dev
I'm not following on the "events" thing you speak of, would I find something just googling "javascript events" and it'd explain?
Alphos
Bruce_dev in theory as well, you could implement them yourself in C or Java. but with C you'd have to pretty much handle everything yourself, and in Java, you'd have to run the java machine, which means half of your resources will be used already. node is considerably lighter for the task
Bruce_dev you certainly would
Bruce_dev
I see. I think I will take some months to learn node.js then
Alphos
Arnas var_dump($id);// you'll know if it's defined or not, and what it is exactly
Bruce_dev : if you have the proper mindset, it's doable in a week
Bruce_dev you'll have to learn to debug javascript, if you don't already know
Bruce_dev
I remember reading an article before and it said that node.js can be backend or frontend, that part really confused me so I figured it'd take me longer to grasp. Guess not then?
Arnas
Alphos, string(1) "2"
Alphos, 2 is correct
Bad_Advice_Cat
(Action) wishes Arnas would use prepared statements.
Arnas
Bad_Advice_Cat, I'm using mysql
Alphos
Arnas where did you put that die() ?
Bad_Advice_Cat
And prepared statements can be done.
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 next »