« first day (1998 days earlier)      last day (3172 days later) » 

user924016
16:01
o/
user924016
@AboutLeros INSERT is a new row, UPDATE is updating an existing row
Anonymous
o/
@RonniSkansing that's what I thoguht. but it don't Faqin work! :D
user924016
yea =)
user924016
When you say it didnt work, did you dump the results, inspect the vars, check for errors and etc
16:02
@RonniSkansing yeah. :/
user924016
@AboutLeros is this the code
user924016
        $stmt = $dbh->prepare("UPDATE users (image_type ,image, image_size, image_name) VALUES (? ,?, ?, ?)");
user924016
?
yeah, that's it.
user924016
So should it update all users or is it missing the WHERE ?
16:05
@RonniSkansing I added WHERE but got an internal error. this: WHERE user_id=".$_SESSION["user_id"];
user924016
Well that would mean you probably have a syntax error
user924016
which could be a good reason why it would not work
@RonniSkansing yeah, I think i put it in the wrong place. just to check, where do it put it?
user924016
=) yea probably or missing something with ' " or )
user924016
try recreating it, so it looks like it should and you have no errors
16:10
Hello all, someone know why is lastInsertId() a method of PDO instead of be a member of PDOStatement? To me is more logic to be the statement which do the insert to be who know it.
@PhoneixS The MySQL function last_insert_id() and other similar statements in other RDBMSs are based on the connection rather than the last completed statement. PHP is just returning what the databases would return, in their same context.
@RonniSkansing Like this? $stmt = $dbh->prepare("UPDATE users (image_type,image, image_size, image_name) VALUES (?,?, ?, ?) WHERE user_id=".$_SESSION["user_id"]; ");
Rough pricing information is available on Intel Xeon Broadwell processors.
@PhoneixS it would be wrong anyway, operations should apply some changes OR return something, not both
We are buying some this year, so it's fun to run some numbers on various configurations.
16:15
@LeviMorrison not too cheap :o)
@bwoebi Xeons never are ^_^
@LeviMorrison :O
@LeviMorrison 22 cores only 4K?
woah
@Ocramius $4,115 for a single socket, yeah.
We have dual-socket configurations - no way are we buying that particular model.
@LeviMorrison We should use those for our Aerys benchmarks. :-D
16:18
Price per core is way too high.
user924016
@AboutLeros almost
We are looking more like the 12, 14, 16 or 18 core models.
Price per core is not the whole story - more cores on a single machine might mean less machines.
But the 22 core model's price is just way too high, as well as requiring too much power per machine.
user924016
' UPDATE ....... WHERE user_id='.$_SESSION['user_id']);
user924016
@AboutLeros
user924016
16:21
unless you have "$variables like that" inside your code, always use single ' in php
user924016
the reason you got the error was the last part you added.
@RonniSkansing ooooh
@RonniSkansing Oak's words echoed, use prepared queries
Thank you both for the answer, @Ghedipunk @SergeyTelshevsky. Now I see it.
@AboutLeros WHERE user_id=?
16:23
@RonniSkansing Internal error :(
@MadaraUchiha ?
@AboutLeros You're already using prepared statements
user924016
He is saying you should also put the user_id in a ? so it 'UPDATE ... WHERE user_id = ?'
Why are you passing some variables as parameters, and some as embedded variables in the string?
user924016
My original guess was that he trusted the session id
@RonniSkansing That's fine
Prepared statements are expensive
And if you have complete trust in your parameters, you shouldn't use prepared statements*
I'll add that * to come back to later
user924016
16:25
=)
But if you're already using prepared statements, there's no point in embedding variables, unless it's table name or limit where you can't pass parameters.
user924016
Did you get the error fixed? I think it is still a syntax error @AboutLeros
A prepared statement has an initial cost of about 50 times a normal query
user924016
Wow, thanks, thats really nice to know
16:27
If you use the same query 50 times with varying parameters in the same session, the prepared statement is worth it.
If you don't, well, it's not worth the performance impact (I'm talking about big apps with thousands of queries)
Also, another thing I learned, calling ->prepare($same_query) multiple times won't incur that penalty
everytime i come on here i realise i know fuck all :D
So you don't have to prepare once, execute multiple times, you can prepare multiple times and execute once for each prepare
The performance would be the same.
(Because the actual prepare cost is on the SQL server side)
@PeeHaa ♬ don't worry... peehaapee ♬
13
@AboutLeros I consider myself a competent developer.
stupid markdown
16:29
I know asymptotically 0%
I know canonically 0%
i just know 0% lol
@MadaraUchiha 50 times? really?
@kelunik Yeah
@MadaraUchiha would you mind telling me the simplest way to achieve this?
16:31
@AboutLeros Normally, people would tell you to do something like this
$stmt = prepare_query($some_query_with_question_marks);
while (something) {
  execute_query($stmt, $params);
}
But that can be suboptimal, you don't always know in advance everything you want to query on
But as it turns out, this is just as performant:
while (something) {
  $stmt = prepare_query($some_query_with_question_marks);
  execute_query($stmt, $params);
}
@kelunik @LeviMorrison when you get these, I definitely need access to produce fake benches :-D
So you can, for example, have a function prepare_and_execute($sql, $params), that will do both actions, and call that in a loop, and it would be just fine performance-wise.
@bwoebi ^_^
@MadaraUchiha that's extremely misleading
@tereško How so?
16:35
i meant to update into mysql, without anything i have done unintentionally like passing some variables as parameters. lol
because you pulled it out of your ass, mostly
@AboutLeros Oh, as a rule of thumb, don't have PHP variables in your SQL string.
@MadaraUchiha In the 99% case, the performance hit does not matter
@tereško I did not. This is the result of benchmarking a wide range of queries on MySQL done by our DBA sometime in the past 6 months or so.
@MadaraUchiha what you are saying is taht, if a query would take 1s, then using a prepared statement it would need 50s
16:36
@DaveRandom Ours is the 1% case, hence we checked.
ant that is complete bullshit
@tereško The first prepare statement, yes.
Also the 50x does sound a little suspect to me, server round trips aren't that expensive
@Gordon Hahahaha
16:37
@DaveRandom It's not the server round trips, as much as the parsing/preparation of the query server-side.
I'll grant you it's a minimum 2x performance cost
@MadaraUchiha Highly RDBMS specific cost area
@DaveRandom True.
he's talking out of his ass, don't pay attention
16:38
I'm speaking for our specific systems
We use MySQL with Java
(don't ask me why)
@tereško Be nice.
I cant
you are spreading FUD
hahahaha!
@tereško That's your opinion.
I could let it slide if you were a newbie, but there should be higher standards for people with blue nicknames
I didn't argue or double-check my DBA on this matter.
I'm not a DBA, and databases aren't my primary focus or line of work
user924016
16:40
Fuck it, I will just run it locally
I know enough to get going
Even prepared queries are often cached.
@LeviMorrison Yes, but the initial cost is higher.
@MadaraUchiha Yes - I understand. Assume it is 50x - what is that cost compared to latency? That's what really matters.
no, it is not
16:41
You get that back when you make the same query again and again
@RonniSkansing yeah, i'll just throw my computer out the window :P
user924016
@AboutLeros so it works now?
the initial cost is only slightly bigger
@RonniSkansing nope)))
@AboutLeros That'd make it faster for sure.
16:41
@tereško It is, but not by that factor.
user924016
@AboutLeros still error?
@LeviMorrison latency is very hard to measure.
@MadaraUchiha please produce a benchmark that backs up your ridiculous claim or shut the fuck up
It's significant when your MySQL server is localhost
@RonniSkansing I wasn't editing it, was to amused by the arguing on here. :)
16:42
@MadaraUchiha Are you sure that you don't know just enough to think you know enough to qualify as competent, but really don't know enough to realize that you're actually incompetent? :-D
@tereško Be nice, I won't ask of you again.
16 mins ago, by Madara Uchiha
A prepared statement has an initial cost of about 50 times a normal query
you made a claim
NOW BACK IT UP
user924016
I shallowed it raw =)
I'd be interested to see that too btw
As for the benchmark, I'm afraid I can't disclose it as it was done internally in the company
16:43
the cost is rather just the additional round-trip to the server; it's rather double cost for most queries
I'll ask if I can post it online though
then you dont have a leg to stand on
I can see a prepared statement being reused being faster, but parsing SQL is much faster than actually running a query anyway
@bwoebi The claim is that the cost is at the MySQL server
Not in the communication
@MadaraUchiha what...? Did you run that without warmed cache?
16:44
@bwoebi Yeah
That's exactly the claim.
AFAIK mysql is caching prepared statements quite efficiently at some initial cost...
@bwoebi Yes, repeated calls to prepared statements are performant, but there's an initial cost
The claim is that it takes 50 repeated calls to the prepared statement to get a performance benefit despite that initial cost.
@MadaraUchiha I am saying, it is caching it … i.e. when you prepare the same query multiple times
not calls to the actual stmt
@bwoebi Yes, repeated calls to prepare don't incur a performance penalty.
@MadaraUchiha @MadaraUchiha that I can believe.
16:47
20 mins ago, by Madara Uchiha
A prepared statement has an initial cost of about 50 times a normal query
1 min ago, by Madara Uchiha
The claim is that it takes 50 repeated calls to the prepared statement to get a performance benefit despite that initial cost.
But you were talking about 50 times compared to a normal query (without any prepare)
no, that was NOT your claim
^ yeah
Right, I'll rephrase
9 mins ago, by tereško
you are spreading FUD
16:48
If you prepare + execute 50 times, it's more performant than 50 different queries without prepare
If you prepare + execute under 50 times, it's less performant than 50 different queries without prepare
Where "different" is different parameters
did you include the operations, that are required for securing against SQL injections, in that magical calculation ?
@tereško I did not.
The aspect of SQL injection is out of this picture
Obviously, if you need SQL injection protection, use prepared queries, despite the perofrmance hit
prepareing queries, that actually dont have variable data, is pointless
16:50
@tereško But let's say you iterate the internal IDs of some table at the application level
your DB data can be source of an injection
@MadaraUchiha How about second level injections?
@tereško I am aware... Say that it is an autogenerated ID...
Again, if there's danger of SQL injection, this entire discussion is pointless.
it is not
I'm also willing to bet in the majority of cases, people iterating over a query, iterate over both the prepare and the execute :P
16:52
Dunno. Those same people most likely just run raw malicious queries
If you mix things, the risk gets higher, even if you know that something is an integer, something other might not or a type might change or ...
Nah I mean, foreach (...) { queryFunc(...); }, and the func does the prepare and the exec, rather than keeping the prepare out of the loop
sure, you'll hit a cache somewhere
I always create new connections in my loops
I think everything runs better on fresh connections
I mean connections are not like wine are they?
@RonniSkansing .. and what did you learn today
As in, you can never have too many connections? ;)
Or, after 20 connections I can still talk properly
16:54

Bugcache

A modern issue tracker. github.com/bugcache/bugcache
Oh that's what I am doing wrong! I am closing connections in between
user924016
@tereško Be moar critical, do my own research, take moar then 1 opinion
That's like drinking the wine, then puking it up, then drinking it again
Thats was fun, but didn't really answer the question.
^ did that room message ping you? @PeeHaa @Wes @RonniSkansing @staabm
16:55
No it did now :)
user924016
Nope
@Leigh Isn't everybody doing that?
@PeeHaa I'm more of a pass to the left kinda guy
:P
Damnit. I forgot my local mysql account
Where is the forgot password link in mysql?
:'-)
root@localhost should be my emailaddress right?
user924016
heh
Got it 'mysqlsuxxx'@'postgres.org' seams to qwork
@Leigh That's cached server-side, no problem.
@MadaraUchiha still unnecessary overhead
17:02
@Leigh No, it reduces complexity.
"it depends"
Now I get to ignore the fact that it's prepared under the surface
I can have function query($sql, $params) { and not care about calling that in a loop with different params
@TyreeBrown Paste, CTRL+K, Enter
Sorry haha. It's not working for me.
@TyreeBrown Paste, press the "fixed font" button that appears, and then press send
there's a big orange button that says "fixed font"
17:07
@MadaraUchiha Why not query($sql, $params, $params2, $params3,...) such that it's looping inside the query function?
function wc_downloadable_product_permissions( $order_id ) {
  if ( get_post_meta( $order_id, '_download_permissions_granted', true ) == 1 ) {
    return; // Only do this once
  }

  $order = wc_get_order( $order_id );

  if ( $order && $order->has_status( 'processing' ) && get_option( 'woocommerce_downloads_grant_access_after_payment' ) == 'no' ) {
    return;
  }

  if ( sizeof( $order->get_items() ) > 0 ) {
    foreach ( $order->get_items() as $item ) {
      $_product = $order->get_product_from_item( $item );
There we go
That helps! Thanks
@LeviMorrison Because my function is general and is not tightly coupled with any loop?
So is this - it yields the results from each query execution.
17:08
My function can run as a standalone, in a loop, in different parts of the app, no problem.
So can this.
@LeviMorrison How? You have a loop in your function...
Which can execute only 1 time if you need it to.
It can execute N queries where N >= 1.
Sure, that works.
What's the benefit?
I had a small question. I was told I could place specific order ID's in this piece of code to grant specific users download access to a specific product. But I wanted to know where would I place my list of order ID's?
17:10
The benefit of pushing that option inside is you aren't relying on the server to cache the prepared query.
And not all servers do, btw.
Well, it's up to you to configure the server, but sure
You can also neglect disabling emulated prepares, and have the entire "prepare" phase happen in the client.
Why let the server do it at all?
Anyway, the idea of having a query function that prepares and executes is a much nicer API whether it does 1 or N >= 1 ^_^
Yeah
Right
Back to Lisp studies now.
I understand $order_id captures the ID's automatically. Could I replace that with a list of specific order ID's? (i.e. 17189, 17184, etc.)
@TyreeBrown do you really want to hardcode those id's in the function?
17:19
Well I ran into a messy situation, and I believe this method should resolve it, so yes. Unless there is a better alternative.
1
Q: How do I bulk generate/grant download permissions on WooCommerce?

Tyree BrownI am in a situation. I have a downloadable product, with over 3500 customers buying it so far. While updating the downloadable product, apparently I messed up and some how removed access to the current 3500+ clients resulting in many confused emails. The customers are still shown as buying the di...

Sounds like there should be some sort of database fix you can apply
sorry, don't know woocommerce
Is there a part of the system where you can manually grant access to one order?
@Leigh You would think there is, but unfortunately no there is not. I also thought about touching the database, but am not sure on the query to run.
how did you break things? :P
user924016
@TyreeBrown did you consider paying a woocommerce freelancer 10-50$ bucks for fixing it?
@Leigh I was updating a downloadable product with an additional file, but ran out of memory. So as I was trying to fix that and somehow it revoked access to the current customers which is 5800+
@RonniSkansing Not really, but now that mention it I am. Do you know of a good website to find credible WooCommerce freelancers?
17:31
you mean you forgot you were updating the product?
gone
user924016
any of the big freelance sites like upwork.. but picking a credible one is up to you
@RonniSkansing Thanks, I'm browsing that website now.
18:01
@bwoebi BTW, when I get something off that list I can do benchmarks - I just can't give you access ^_^
So if you put together something for me to run I can run it.
@LeviMorrison a chroot jail is enough :-P
But seriously, if on one machine we run on 32 cores and on another machine on a high-speed network we bombard it with requests - we can get some pretty good, pretty close to real-life numbers.
yeah
But if we are going to do this we should do this right, with different web requests. I always hate it when benchmarks are hitting the same page 1,000,000,000 times.
That happens only when an article or page goes viral - irrelevant at all other times.
hello anyone has used twilio service ?
18:11
@MadaraUchiha citation needed please.
Or just even a random test case.
@Danack I don't have one readily, it was a benchmark done internally in our company
I'll ask tomorrow whether I can publish it.
for the record - the only reason to not use prepared statements is usually to avoid two round trips to the DB, rather than a performance reason preparing the statement.
@Danack My DBA claims otherwise
He claims the (initial) cost is preparing the statement itself on the server side.
Subsequent calls to PREPARE on the same query incurs no such penalty.
Not sure if genius or annoying
18:33
posted on April 05, 2016 by bwoebi

amphp/aerys-session v0.1.2

18:47
@PeeHaa annoying, definitely annoying
Yeah I thinkI'm also on the annoying side
@PeeHaa Your code is on strike

« first day (1998 days earlier)      last day (3172 days later) »