« first day (1269 days earlier)      last day (3679 days later) » 

11:24 AM
Hmm guys i'm getting a near correct output, I'm counting the amount of columns this table has I have but i'm getting the total amount but I need something like:12345 instead of: 5.
 
@DavidH You mean 00005 ?
 
    I've done this:
    $sql_assoc = some select query;
    $num_cols = count((array) current($sql_assoc));

    echo $num_cols;
@HamZa Why would you think 000?
 
/forget what I said
 
Hehe no problem.
 
@DavidH Well, if you have the final number, and all you want is to print 1..n, where's your problem?
 
11:29 AM
@SecondRikudo I essentially need it to output the count itself(While it is counting)
 
It doesn't work that way.
count() doesn't allow you to do that.
 
Hmm is there a different command applicable in that case?
 
Sure, iterate through the array and count yourself.
May I ask why the hell do you need this?
 
Haha! Well i need it in a for loop! Also could you explain that a little more, I didn't quite get it.
Oh wow wait.
Do you mean counting it through a for loop(By saying iterate through the array)
 
@DavidH Yes
 
11:34 AM
This will be my death..
 
I ask again, why do you need this?
 
wait
@DavidH you need to send that query to mysql...?
 
this is getting to the point where it is not even funny anymore: project manager told me that I need to add an ability for client to set custom HTML banners for product categories which have sales .. thing is: project has no CMS, because client said that they don't need it
 
where is your array supposed to come from?
 
I need it in a for loop in which i'd count the results of each certain ID.
@iroegbu Nope I just need it defined in a variable.
The result that is.
 
11:36 AM
ok, make a paste of your problem. Don't attempt to provide any solution what so ever.
 
@DavidH Answer me this: What are you trying to do? Leave out the how please.
 
@SecondRikudo I need the result of that Count(All the numbers) in a for loop that would check values in the database written as integer. Usually i'd use field_count but since i'm on WP I can't use mysqli. That's why i'm trying to find a work around for it.
 
@tereško :o show him feature list maybe
 
also .. what the fuck is which project managers, who think that the best way to finish project today is constantly pester me about "did you read the mail?", "can you write an answer to the client?" , "have you read that post, which I wrote 5 minutes ago on Basecamp" .. and he's on sype again
 
@DavidH That's the how, not the what.
 
11:40 AM
@SecondRikudo I'm trying to count the columns of the query.
Actually it's the why :P my bad.
 
just now asked "what functionality is provided by languag-based filers in your application? Is it what client expects? How does it interact with their API?"
.. I am tempted to just go up to him put a resignation on his desk
 
maybe you should call for a strategy meeting where SLAs and OLAs will be discussed.
 
and then go to sleep, because I have been awake for 30 hours
 
hey guys, quick quesiton. Does anyone know if this empty function will work in PHP v 5.1.3? (!empty($_POST['action']))
i saw this note in the php manual: Note:
Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.
 
@tereško So glad we dont have one in our team
I've worked with a pm before
and it's such a PITA
 
11:48 AM
the are good PMs and there are bad PMs
 
I've never experienced the former
 
I have - twice
 
Where I am here we have someone who kindof does PM role, but his main role is to protect devs from pestering
Has a lot of technical knowledge, but he's the business-dev liaison
 
our PMs main role IS to pester devs and he has no clue about how websites are made
 
Yeah, that's what my last PM did
Constantly Skyping & emailing you asking "Can you look at this"
And also my favorite, answers rest of business with time estimates which are totally based on ignorance
 
11:50 AM
anyone know the answer to my question? :(
 
$pdoQuery->prepare("DELETE FROM site WHERE date_voted < DATE_SUB(NOW(), INTERVAL 12 SECOND");
 
"Yeah, we can do that today, no problem"
 
Do you see a syntax error in this query?
 
@user3123545 Missing bracket after SECOND
 
Ah thanks
 
11:55 AM
@redshift : use isset()
 
@KarelG this is what I have, will it be adequate? if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty($_POST['action'])))
 
if (isset($_POST['action'])) { ... }
is fine
 
FFS
 
but you have to check the submitted data again too
 
10 more minutes & train of thought lost to confused PM
 
11:57 AM
@redshift Check the manual entry for empty
It says which version is supported at the top.
> PHP4, PHP5
means it's supported since PHP4.
 
thanks!
back to your regular scheduled programming
 
Today I learned how much of an impact database indexes create... -__-
 
np ! /moves away
 
overlooking one* more like it
 
As an experiment in good practice, I'm requiring a given getter function to receive an instance of a given type of class so as to ensure that only functions that have an instance of that class on hand can use that given getter.
Only issue is, a static method of that particular class cannot use it because it's own static self isn't an instance of itself.
 
12:06 PM
@Hamster ... What?
Do you have a code sample?
 
good morning!
 
@SecondRikudo Uh, here: codepad.viper-7.com/Uex9k2
The only solution I can think of would be for the static method to provide a bogus instance of Test, but that's silly.
 
@Hamster There's one more. Don't use static scope at all.
 
@Hamster 1. Don't use static
2. An object is responsible for creating itself, that's why a factory is supposed to be a different Object
 
Yeah, that's why I edited to indicate it wasn't a factory method. I used the wrong term.
 
12:15 PM
In web programming (to be more precise in environments where nothing is shared between sessions) there's no actual reason to use static scope. While using shared resources you add maintenance problems while solve nothing unless resource can be shared between different sessions/processes.
 
@JoeWatkins I hear websites are not working :D
 
@Leri Without using static methods, I'd have to refactor my code to use singleton classes for performing functions originally meant to be within scope of other classes, which would mean also refactoring those classes to control for what gets to access those functions from the outside (such as via. my example).
Unrelated: What's the term for a static method that generates an instance of its class instead of using a public constructor?
 
received a valid answer on a question, but it's too goddamn slow :-/
 
*"originally meant to be within scope of other classes" -> "originally handled by static methods"
 
12:30 PM
@Hamster factory method
 
@Hamster By singleton classes do you mean static (probably, lazy) singleton implementation?
@bwoebi Link to answer, please. :)
 
@Leri No, I mean to AVOID using static methods, I'd use (non-static) classes that only exist in singleton instances.
 
1
A: Incrementing counter on each duplicate in column

m hasanWhat you are trying to accomplish is called RANKING . Unfortunately MySQL doesnot have ranking functions like in SQL Server ROW_NUMBER() , DENSE_RANK() etc.. You can try below query for MySQL SELECT t.ID, t.Value, count(*) as Counter FROM tableName t JOIN tableName b ON t.ID = b.ID AND t.Value >...

 
@Hamster Yeah, that's perfectly sane. So if your code needs refactoring, why won't you refactor?
 
@Leri Which I might consider doing, now that I think about it. While static makes sense for many things I'm doing, I don't like some of troubles it gives me.
 
12:33 PM
@bwoebi you may try with variables. Will be FULL SCAN, but not O(n^2) (i.e. Cartesian product)
so bad too - but better that blind JOIN
 
@AlmaDo full scan is necessary anyway as I need to use the whole result later...
 
@bwoebi then use variables and be happy (:
 
@Hamster Static only gives trouble everywhere. It's just sometimes pros worth those problems. For the web http world the latter is never the case.
 
Troubles such as the one I mentioned earlier, for instance.
 
@AlmaDo will try…
 
12:38 PM
@bwoebi this will break original order, of course - but since you need all rows, I think it's not a problem
 
@bwoebi Why on the world you have duplicated data in id field?
 
@AlmaDo I can reorder, that's my least problem
Btw. your query took only 0.3 secs, muuuuch better :-)
 
@bwoebi for 20k rows it will be fast (not like JOIN as it'll take 2E4^2 rows)
 
wait…
@AlmaDo your query just adds a counter, but not depending on the id row?
just adds a global table counter?
 
why? depends.
num field should work
before:
mysql> select * from t;
+------+-------+
| id   | value |
+------+-------+
|    1 | x     |
|    2 | x     |
|    1 | y     |
|    1 | z     |
|    2 | y     |
+------+-------+
5 rows in set (0.00 sec)
and after:
+------+-------+------+---------+
| id   | value | num  | @id:=id |
+------+-------+------+---------+
|    1 | x     |    1 |       1 |
|    1 | y     |    2 |       1 |
|    1 | z     |    3 |       1 |
|    2 | x     |    1 |       2 |
|    2 | y     |    2 |       2 |
+------+-------+------+---------+
so it's re-ordered, yes, but num is id-value dependent
 
12:49 PM
I just can't reproduce your result :x
 
? I can add fiddle :p
 
Ah fine…
no… the id is in the real table a varchar…
I just needed to use LIKE instead of =
and it worked^^
 
so.. your query is .. ?
 
@AlmaDo SQL fiddle everything!!! :Ь
 
@Leri this wouldn't help since there's special condition which wasn't mentioned in question :\
 
12:51 PM
@AlmaDo I was just kidding. sigh
 
my bad.. I couldn't imagine that id isn't only non-unique - it's also a varchar Oo
 
@AlmaDo @i:=IF(id LIKE @id, @i+1, 1) … that's all what I needed to change
 
I see
 
@AlmaDo no, it's not your fault ;-)
 
that was a joke (c) :p
 
12:52 PM
It was correct based on what I indicated in the question^^
but... great answer!
 
I'm a very evil man when it comes to sql (: @Jack knows
 
@AlmaDo E_BANK ?
 
yo
 
hi, @Duikboot
@Leri ?
 
When I have z:\A\Alfa\Cool_cars\document.docx is that an URI ? Or a URL ?
 
12:54 PM
@AlmaDo sql is overused in banks. Is working too much in banks the reason why you become evil when it comes to sql? :p
 
But great idea, I hadn't thought of sorting and then beginning every time again at one…
 
@Leri ah that. Hm.. close (own billing system) - but no, nothing to do with banks. I just like SQL
 
A Uniform Resource Identifier (URI) is a compact sequence of
characters that identifies an abstract or physical resource.
 
One of my "evil" techniques is eval for mysql and parsing Jaywalker (:
 
One should be afraid of you. :P ^
 
12:57 PM
yeah
may be I'll like Haskell
or even Lisp
 
Off to real work. Later
 
Ugh why is it always a problem to combine foreach's with for loops...
 
Sounds smelly
 
ha smelly lol
how is everybody?
newbie here!
 
Not so good..
Hope you're fine
 
1:06 PM
Aww why?
 
I have bad feelings
 
Been at it for a week on the same task which is simple...
Just can't get my head around it :)
 
Can I help? Well I need help so not to great myself but still have a smile well the alternative would smashing the notebook.
 
Ohe well..wordpress
Oh*
 
ok well dabbled with wordpress. Not expert could try?
 
1:08 PM
Well it's actually php related
It's just that WP doesn't really support mysqli unless you make it
So i'm stuck with mysql_*
 
ouch
 
But it's so strange how you need to do things
 
It's almost as if you shouldn't use WP :P
 
Yea the main issue is that I need to nest Foreach's and For loops..
I wouldn't if I could but i'm an intern xD
This company uses WP so to bad for me :P
 
If you're an intern than it's okay to ask for help from your peers. Last thing they want is you spending too long on an issue when you could just ask.
That's part of being an intern
 
1:11 PM
Yep you're right but the backend coder isn't here and the front end coder is as stuck up with it as I am :P
 
Give us a snippet?
 
Hmm sure give me a moment
 
New question , mysql related. I'm holding sessions in the database using zf 1. The garbage collector cleans up the old sessions, but increment keeps increasing, is there a possibility of it topping out? like char(32) not being able to hold any more sessions because of how larger the sessionid is?
 
Could anyone help with my mess as I'm sitting at home no one to ask and banding my head against the desk in working it out every possible way to find it just does not want to work. I have made a mess of it but the bit I'm concentrated on is the retrieval of URL's at the moment PHP does not like my query coming back as an object for which I tried few answers found on here but they pull up more errors
 
Oh actually guys I think I found something that's not right...
Hopefully I can solve it
Found it as I was making the snippet lol
 
1:16 PM
:D Nice
 
@KP2012 You're beyond me I can't help sorry >.<
 
What a cute picture of @tereško :D
 
thats fine @DavidH
 
Some Syntax highlighting should make it cooler. @KP2012
 
xD
 
1:19 PM
@Duikboot //Query to fetch URL Select externalpage field which contains the url from the content_description table
$q = mysqli_query($dbc, "SELECT externalpage FROM content_description", MYSQLI_USE_RESULT);

//convert query object to string
$url = (string)$q;

// URL to crawl
$crawler->setURL($url);
sorry no idea how to highlight on gist
 
Errors are cool. WIch one your receive?
 
It's expecting a string not an object I get that and when converting it does not want too
Warning: trim() expects parameter 1 to be string, object given in C:\xampp\htdocs\development\Uni\PHPCrawl_082\libs\PHPCrawler.class.php on line 1095
 
@KP2012, which line? o_O
 
Have you find out wich line that triggers?
$crawler->setURL($url); ?
 
1:23 PM
you shouldn't to do this -> $url = (string) $q;
 
It triggers from the PHPcrawl library files becuase it expect a simple 'http://blabla' url but instead I push a query generated URL into it so it does not like that
that how should I do it sir/mate/fellow_coder?
 
Yeah that was clear. But Wich line in your code or better, after wich line is the error given?
 
you should fetch it before
 
@Duikboot I think he can't see it without stack trace.
 
@AlmaDo just fyi: it was to optimize LIMIT + OFFSET lookups with a WHERE clause on the id column. Getting results from the memory table in less than a millisecond now :-)
Takes maybe 2-3 seconds to generate, but it's generated just once every 24 hours, so, no problems :-)
 
1:27 PM
optimizing LIMIT+OFFSET is usually done with PK scan (very efficient way)
 
PK means?
 
@Duikboot stack trace?
 
primary key (if it's present)
 
$q = $q->fetch_assoc(); $url = $q['externalpage'];
 
thanks for the above @AlmaDo and @bwoebi
 
1:29 PM
@AlmaDo not sure how that looks in practice…?
 
Nope x.x i'm screwed
 
@PeeHaa late response but fantastic question. we should be at the top of that list
 
@vp_arth the line creates Undefined variable: q error
 
@bwoebi it's done with statement: first, select id for first portion of data (i.e. LIMIT 0, COUNT). This will be fast since it will be done from 0 row. Now, we know what id corresponds COUNT. And to select next page, i.e. LIMIT OFFSET, COUNT - we are able to get rid of LIMIT and do WHERE id>@found_id LIMIT COUNT
 
@KP2012, you should check that mysqli_query don't return false)
 
1:31 PM
selecting by PK is extremely faster, selecting first COUNT rows is also very fast
thus, no additional table is needed
 
Anyone know if in PHPStorm you can "proxy" an @method call via a factory so it doesn't show up a load of undefined methods in my code?
 
@KP2012, try to read this
 
Without putting @returns Object1|Object2|Object3|Object4 ...etc... within my factory phpdoc
 
@AlmaDo well, yes, I needed to generate that id/num/counter column first...
 
1:36 PM
@bwoebi you don't need to generate it - just quick find desired @id and that's all. But - yes, the way that you're doing it now is good if data won't change too often
 
@Jimbo you can mark result with Base class with @var
 
@AlmaDo problem was actually that I have intentional duplicates in @id column ...
 
@Lusitanian woah that is a late response :)
 
why need you enumerate it, factory should returns instances of one parent class, mark @returns SomeBase
 
@PeeHaa and a low response. what's up
 
1:38 PM
How's life dawg? Busy?
 
@bwoebi then you have no PK (: and that's bad case :p
 
Good morning
 
hi, @ircmaxell
 
@AlmaDo the PK is over two columns.
 
What's up?
 
1:38 PM
@vp_arth Before, I had only docblocks above my classes with @method for using with __call(). It worked great. Then I moved the instantiation of these objects into a factory. Now, these methods are undefined and I don't want to have to add /** @var ... */ above every single one
 
@bwoebi then it's ok. you should do similar way (i.e. find pair that corresponds COUNT)
 
@Lusitanian Busy at the job and I also have been somewhat busy with the lib. I'm going to merge the file upload PR soon
I even added a new service last week :D
 
@AlmaDo I think it depends on the specific case…
@ircmaxell morning
 
@Jimbo make some Interface and mark all factory returne classes as implements it, then @returns it
 
1:40 PM
@bwoebi well it's common solution for optimizing LIMIT+OFFSET issues..
 
@vp_arth Nice idea, I'll give it a go, thanks :-)
 
@PeeHaa at least one of us has done actual work on that :)
 
@AlmaDo actually in most cases you have just a simple autoincremented primary key without any special where clauses or so…
 
@PeeHaa I've finally picked a university (starting over summer) and am finishing at my current job in the mean time
 
btw. @AlmaDo the table I operate on is already a subselect… temporary table needed in every case here.
 
1:43 PM
@bwoebi that's why I've said in common case :p
 
yes, sir :-P
 
@Lusitanian cool
 
@PeeHaa lol
 
@Lusitanian Congratulations and welcome to your nightmares for the next 15 years - xkcd.com/557
 
Soooooo I presume you have been busy banging college chicks in the mean time? :) @Lusitanian
 
1:49 PM
@Lusitanian Good luck!
 
@ircmaxell Thank you :)
@Danack lmao
@PeeHaa confirmation/denial is not available at this time
 
;)
 
College rules... com.
 
I'm a new pony now
Have to change my pony every few months
It's the rules.
 
@AlulaErrorpone nice to meet you :D
@rdlowrey @tereško @HamZa blag.xkcd.com BLAG, IT'S A BLAG
 
2:11 PM
@AlulaErrorpone WHO ARE YOU?!
 
@salathe I'ma pony
 
oh, hai.
 
I'ma filly alicorn errorpony
 
eih
 
2:16 PM
@bwoebi if you're interested, this is what I'm calling eval technique for mysql :p
 
@Lusitanian congress .... +1
 
> I’m currently looking for a Senior PHP Developer for my client based in Berlin to start work ASAP. This is a 3 month contract and will be paying €400 - €450 per day. If you would like to know more information please send me your updated CV. To clarify, you will need to be willing to work in Berlin to be considered.
One for @webarto? :)
or a relocating @tereško
 
400-450per day sounds good
 
*wouldn't mind 450 per day* :D
 
@AlmaDo that's like writing PHP with mysql.
 
2:23 PM
May be you live at very costly place and not single :p
 
22 days.. it's 10.000 per month? yay.. hard to imagine what should be that work
 
in europe, that's a lot
in the US, that's low ;-)
 
@bwoebi sad, but sometimes we have to deal with prepared statements like that..
 
Here ..in India that's immense
 
2:26 PM
@ircmaxell hm.. 10.000 EUR per month is 120.000 EUR per year. rate is 1.37 now so it's 164.000 USD per year. Is it low?
 
Well if anyone wants the email contact, let me know. Forewarning it's a recruiter.
 
For 1k$ per month government job here we have to study 16hour per day
 
@AlmaDo perhaps not low, but... ;-)
 
@ircma
 
also don't forget the take-home is far less in the EU from that
 
2:27 PM
@ircmaxell I don't know, just asking (: never worked in USA
 
my tax rate there would be like 25%, so I'd take home 123k, where in the EU, the tax rate there would be closer to what, 50% or 60%?
@TobiasGies hey man! How's it going?
 
@ircmaxell I'm surprised. What would be a good salary for the Valley area?
 
Lol 50-60% tax rate
 
@ircmaxell heya! I'm fine, hope you're good too
 
50-60 is true in some countries
 
2:28 PM
Its loot :D
 
I pay ~15%
 
50-60% tax rate, lol
 
it's not a strict 50-60 though. Only 50-60 on everything above 'x' earnt.
 
Good morning.
 
depends on if you factor in sales tax, I guess.
 
2:29 PM
@Fabien well, then you need to earn >30k/month
 
@Fabien well.. 160k USD is definitely 'higher than x'
 
I even don't pay due to nature of my work
 
@TobiasGies that would be low-to-average in the Valley, and in NYC
 
@Fabien also sad, but I don't know german (:
 
So the first £34,999 is 20% here, then 40% until £150,000 Source
 
2:30 PM
@Fabien what would the effective tax rate be though?
 
@AlmaDo It's only 3 months though
 
@Fabien yeah. that's why relocation isn't good idea
 
We also have tax free 0-10k actually
 
^ per.. what?
 
PHPDoc - anyone know how to doc @return but multi-line?
 
2:31 PM
Lol 10k you mean for BPL
 
When you get high enough salary your tax goes down :p
 
@Fabien here it's tax free until ±25k/year
 
I lose about 16% of my income to the taxman, with another 20% going to social security (healthcare, retirement fund, etc...) the rest ends up in my bank account.
 
@bwoebi Nice.
 
@tobias still its too much
 
2:33 PM
I wish they stopped making it mandatory to pay for retirement.
Or if I died before I claimed all of what I paid it could be inherited
 
@TobiasGies that's not bad. Mine is similar (about 25% to taxes, and 15% to heathcare + retirement + etc)..
 
@ircmaxell wee-ell, it gets worse when you factor in that I pay 19% sales tax on almost everything except food, 7% for food
and that comes out of the amount that actually hits my bank account.
 
That's too much
 
user895378
@JoeWatkins is there any way to kill a pthreads Worker thread by doing something stupid in a Stackable? I know fatal errors are generally swallowed and the worker transparently recovers. Is it totally impossible to kill the worker even with something like an out of memory error?
 
@rdlowrey hmmm… try it?
 
user895378
2:37 PM
I just thought I'd ask first :) I haven't been able to kill one yet.
 
user895378
Even with fatal E_PARSE errors.
 
user895378
I'm wondering because I'm doing some voodoo that could result in segfaults if a worker died off unexpectedly.
 
@TobiasGies 10% on everything, 0% on food. Except for by my house, which is a "economic development zone" which means I pay 3.5% sales tax on everything instead ;-)
 
@ircmaxell want
 
;-)
 
2:50 PM
@rdlowrey I highly doubt that you can kill the worker via killing the Threaded; except if you kill the worker directly by something else…
It's a zend_bailout() black box…
 
user895378
@bwoebi That's what I figured ...
 
user895378
(which is good for my use-case)
 
user895378
I'm keeping references to socket streams in worker threads once they're used there (avoids segfaults from sockets being GC'd in the worker). I periodically clear those references later after the sockets are closed in the main thread.
 
user895378
As long as the worker doesn't die (and prematurely close a socket that's still open in the main thread) everything should be fine.
 
Happens to us all in many different situations.
Like pooping when a parcel is coming.
 

« first day (1269 days earlier)      last day (3679 days later) »