« first day (426 days earlier)      last day (4522 days later) » 

2:00 PM
@edorian Good one.
 
@manan the main issue seems to be that "mysql_query_debug" isn't a php core function php.net/manual/en/ref.mysql.php
 
@edorian but in my localhost it is working
and on live site it is not working
 
@manan Go with PDO it's native and way more portable and error-prove.
 
Yeah but you can't really expect us to help you with a function that doesn't even exist in php but comes from some random source on the internet (or was written by you) that nobody knows about or has used for years :)
 
actully i am using thired party code ... they are using many of the time this function in his code
 
2:03 PM
> ... but it works on my localhost.
 
@OmeidHerat yes
i found the issue,so there was a custom function for mysql_query_debug() in my third party code
 
I never realized how big PHP arrays are, is there any alternatives to this in PHP?
 
@NikiC Nice spread you achieved with this :)
@Incognito There is SplFixedArray, not creating massive arrays but using iterative approaches and not caring about it until it is a measurable problem
option 3 usually works really well
 
2:18 PM
well // i think people are missing the fact that arrays in php are not arrays !!!
 
I've never seen SPL before, is it like the STL in Cpp?
@tereško The naming convention is somewhat confusing, but that's par for the course :P.
 
@tereško php arrays are php arrays, shouting around lamenting common names doesn't change anything :)
@Incognito You have never seen SPL? Half of phps useful core functionally is there. Go check that stuff out
Especially the iterators
 
when you say that arrays in php are large , there are reasons for it ( besides the "php sucks" line of reasoning )
 
@edorian Yeah I'm just seeing this now, I feel like the world's most epic face palm is imminent.
 
@edorian Though I think that people are largely misunderstanding the article. It was meant to be purely technical, but I think people are reading it as "Oh my god how badly is PHP written?!"
 
2:21 PM
btw , talking about SPL : what is the state of autoloader ?
was it included ?
 
no
 
@NikiC I haven't seen anything hinting that too me
Apart from the "Use can't say php without people shouting their favorite language specs at you"
But you also get that for saying "string" and "php" in the same sentence
 
class test {

	function __construct(array $arg) {

	}

}

new test(function(){return array();});
 
E_FATAL
 
shouldn't work
 
2:24 PM
> Catchable fatal error: Argument 1 passed to test::__construct() must be an array, object given.
Why ?
 
Because you pass in a function and not an array
 
because anonymous function is NOT an array
damn you
 
but lambda isn't suppose to be parsed ?
 
when you define the anonymous function , it is not immediately executed
 
$x = function() { return 5; }; var_dump($x);
This is not 5.. and why should it
If creating anonymous function would insta execute them they would be useless
 
2:26 PM
So even $array = function(){ return array();} shouldn't work in test($array) ?
 
Maybe read up on how functions work
 
@OmeidHerat see here:
//Defines foo with val
var foo = function(val){
    return val
}

foo(1) //Calls foo wit 1

//Defines with val and calls with 1
function(val){
    return val
}(1) // returns 1 as an evaluated function call.
 
well .. in javascript you kinda can instantly execute the anonymous function , but the said function then actually returns another function , thus serving a but different purpose
 
That function(){ return 1;}(); doesn't work in php might be fixed in 5.5 though :)
 
I've never really needed to do (function(){})() in php, it just doesn't seem to fit for any reason.
 
2:29 PM
@edorian that there was JS
 
@tereško I should have made that clear in my sample code.
 
@tereško Yeah yeah, i know. I've done that in JS where i had uses for it ;)
 
btw , @Incognito , you suck at semicolons
 
@tereško True story. Normally, I'm the semicolon OCD case. I don't know what's happening to me.
 
@tereško @edorian the anonymous function is actually executed !
this filthy trick works ! new test((array) function() {return array();});
 
2:31 PM
how about you learn about functional programming before using parts of it in php ?!
 
I probably wouldn't use FP in PHP =/
 
Now that I think, if anonymous function isn't executed the when it's ? there is now way to call it later as it's anonymous.
 
If I did, I might as well use the Lua extension :P
 
@tereško </elitism>
 
and casting instance of Closure as array is stupid
 
2:33 PM
@OmeidHerat functions are data, you can pass them around.
That may be an overly broad statement.
 
do you have a point ?
 
5 mins ago, by Omeid Herat
this filthy trick works ! new test((array) function() {return array();});
3 mins ago, by tereško
and casting instance of Closure as array is stupid
:P
@Incognito Yeah I see. $function = function(){....}; $function()
 
@OmeidHerat That's not really what I meant.
 
then ?
 
2:41 PM
function sort(data, test){
  for (i...){
    /*Some sort mechanics*/
    if (test(data[i])) {
      /*Some sort mechanics*/
    }
  }
}

sort(
  someData,
  function(a, b){
    return a > b
  }
)
 
@OmeidHerat Please just read up on how those functions work. It's nicely explained in the docs
 
Sup
@OmeidHerat It does not do what you think it does
 
@OmeidHerat What you said there is that (array)"Hello" works if the function expects an array :) Ofc that works because you make an array out of it
 
@Incognito same thing, but main was over simplified :)
@ircmaxell the something similar like __toString() should be happing there. or ?
 
@OmeidHerat Your example assigned an anonymous function to a variable... mine uses the anonymous function as a means for a code-reuse pattern which could be used to create different sorting methods.
 
2:44 PM
0
Q: querying a hierarchical mysql table in php

loveshi have a table with 3 columns id,name and parent_id representing categories. The root categories(categories with no parents) have parent_id 0. All other categories have parent_id as the id of their immediate parent. There is no limit on the depth of categories i mean that a category can be 3,4 or...

 
@OmeidHerat Nope
 
@Incognito You are passing the function as a argument which is which is essentially called by the function you pass, while I call it myself. or i am missing something ?
@ircmaxell then ?
 
the besst way to understand it would be for you to learn javascript
 
@OmeidHerat Yeah, I'm showing how it can be useful rather than how it can be assigned to a value.
 
but that's just my opinion
 
2:49 PM
@tereško I agree with this.
In php, lets say you have a 2-d "Array", how could you sort by values on the fifth key?
 
@tereško aight, I think I should find the Douglas Crockford book again, I really read it this time.
 
Well: "Anonymous functions are not eval statements that create variables but creating proper php functions that need to be called for them to execute" might also do it :)
 
@Incognito Like ?
 
@edorian By 5th key, I really mean n'th key
 
2:53 PM
@edorian I think I got it. :) was fooled by that Typecasting results.
 
I have a quick question - regarding DOM Xpaths.. how do I combine two conditions e.g. //a[contains(@style, 'font-weight:bold') and contains(translate(@href, '0123456789', ''), 'showthread.php?t=', )] ?
 
@Incognito usort($array, function($a, $b) use ($n) { return $a[$n] > $b[$n] ? 1: -1; } );
with a properly filled in function body
 
@Incognito I don't get sorting by n'th key. I might be able to help you.
 
@edorian It was more of a thing I was trying to pose to Omeid about how you can use these functions.
 
I didn't get that. Never mind then :)
 
2:56 PM
It's a problem I solved by using almost exactly what you've done, but showing how you can pass functions as arguments for code reuse.
 
sorry for the spoiler then :P
 
I just entered Win a Paid GitHub Account for Life (worth $8,000!!)! http://appsumo.com/~aVnU via @appsumo
Oh and good morning :-)
 
@edorian Hahah :) It's alright. I'm just looking for examples of how FP might be useful, but PHP doesn't suit FP the way other languages might.
 
@Incognito I have been using anonymous functions for a long time now, I think since it popped up on 5.3 what is new !
 
god that appsumo spam is getting annoying
 
3:01 PM
Again, if we want to use FP in PHP, use php.net/manual/en/v8js.examples.php or php.net/manual/en/book.lua.php
 
Sep 30 at 10:56, by Omeid Herat
array_filter($data, function($Node) use ($testTimeStamp) {return $Node['Modified'] > $testTimeStamp; });
 
@edorian :-P who else posted it?
 
How does Judy stack up against SPL and the native array?
 
By the way, there is also pecl.php.net/package/quickhash ;)
 
I have a handfull of PHP scripts that do things like aggregate data from three DBs (mssql, mysql, postgresql) and dump it to one display on the user side, faster arrays would be amazing.
Right now these arrays are my bottle neck.
 
3:05 PM
But honestly, I wouldn't worry about array size until you really have problems with it :)
 
@NikiC I have a problem with it :P
Sometimes the server delay can be up to five seconds.
 
and you profiled it and the array is really the bottleneck? not the queries or such?
 
SQL queries are instant, it's just merging from several databases and presenting them as one that's the issue.
 
@Neal Everyone on twitter for 3 weeks :)
 
@edorian I only use twitter to yell at people.
 
3:08 PM
@NikiC why do I feel like PHP is going toward a strong-typed language ?
 
If it where up to me PHP would be going towards autoboxing java but it will never be strongly typed without massive automated conversions for primitive types
 
@edorian lol well i ddnt know that :-P I dont tweet (see my account)
 
@OmeidHerat figure out what you want to do
 
@Neal I'm mainly annoyed that their marketing is working so well
 
Ive only been tweeting for free stuff lol
 
3:11 PM
Spending 200 bucks for that amount of exposure is amazing use of money
 
@ircmaxell is this about PHP-going-toward-strong-type or the closure type casting ?
 
You can't meaningfully cast a closure in any case
 
True, but I am not sure how this works ' (array)function(){return array();} `
 
and closures don't have anything to do with strongly vs loosly typed
 
this works
$foo = new StdClass;
(array)$foo;
which is exactly what's happening
 
3:14 PM
php -r' var_dump((array)function(){return array();});'
array(1) {
  [0]=>
  object(Closure)#1 (0) {
  }
}
 
function() {} basically returns an object
 
....
 
@edorian Ah! that says it. So the object is not converted at all, its more like (array)(obj) then (array)obj
 
Just like casting a string to an array
 
so in fact (array)obj is array(obj) and they call it typecasting in PHP :P
 
3:19 PM
no
 
on@machine:~$ php -r 'var_dump( (array)function(){} );'
array(1) {
  [0]=>
  object(Closure)#1 (0) {
  }
}
on@machine:~$ php -r 'var_dump( array(function(){}) );'
array(1) {
  [0]=>
  object(Closure)#1 (0) {
  }
}
@ircmaxell I think yes.
 
I really feel like I'm getting trolled
 
@edorian why ? try it yourself, (array)obj === array(obj)
 
 php -r' $x = new stdClass(); $x->x = 5;  var_dump((array)$x);'
array(1) {
  ["x"]=>
  int(5)
}
 
@edorian and I never said anything like that.
 
3:25 PM
1 min ago, by Omeid Herat
@edorian why ? try it yourself, (array)obj === array(obj)
stdClass instanceof object
 
on@machine:~$ php -r 'var_dump( array(function(){return 5;}) );'
array(1) {
  [0]=>
  object(Closure)#1 (0) {
  }
}
on@machine:~$ php -r 'var_dump( (array)function(){return 5;} );'
array(1) {
  [0]=>
  object(Closure)#1 (0) {
  }
}
 
why are you trying to cast a closure? That makes no sense
 
I am not sure if stdClass is same as closure.
 
But yeah. I don't seem to be able to communicate to you in a way that makes you understand those basics and trying makes me really want to punch you
 
3:28 PM
because it all start there.
 
So I'll just (finally) leave it alone :)
 
@edorian aight. thanks for trying :)
@ircmaxell Because
17 mins ago, by Omeid Herat
True, but I am not sure how this works ' (array)function(){return array();} `
 
Evening!
IS there a way to access first and last elements of array if I know that there will be at least two of them?
Currently it is plain
$values[0] = (int) $min;
$values[ count( $values ) - 1 ] = (int) $max;
And I don't like it.
:)
 
$first = $values[0]; $last = end($values);
 
Isn't it for getting a value?
 
3:35 PM
reset($array); $first = current($array); end($array); $last = current($array);
 
Ou sorry.
It moves pointer
Thank you
Both
 
But I'd rather not use that to be honest
 
end() moves the pointer and returns the value ;)
me neither
 
Moving around array pointers never solved anything nicely imho :)
 
I always the approach you posted initially
 
3:37 PM
or if the array is not consecutively indexed $x[max(array_keys($array))];
It's ugly but at least it shows of that something strange is going on
 
@edorian In that case I would prefer end() though
 
Code should highlight data structure problems :)
@NikiC "The biggest value" vs. "The last value"
I worded it a little wrong
 
and sometimes array_pop is the right thing.
 
oh now I get it :D
 
@OmeidHerat Good point :)
 
3:39 PM
@edorian if you want the biggest value, it should be array_values or you get the biggest index/key :)
 
the highest index.. something :P
 
not to mention, that max($array); works perfectly :P
 
The whole thing was about accessing the highest index ;)
 
I know, I was just being picky :D
 
3:59 PM
 
?
I am off.
Peace out.
 
4:46 PM
Man, really glad I started unit testing..that bug would have been painful to squash without it.
 
5:11 PM
yes, I found that unit testing finds more bugs than one might expect ;)
 
5:49 PM
@NikiC not only does it find more bugs. when you practise tdd, it will also prevent them and make you think more about your code.
 
@Gordon Famous last words
 
user680786
I worked hard so was not in chat for a long time. Hi @all, what's up?
 
6:05 PM
hi @OZ
 
Howdy.
 
@LeviMorrison howdy.
 
@ircmaxell not at all
 
@LeviMorrison what about it?
 
6:07 PM
@NikiC You up for working on that, too?
 
@LeviMorrison No, I don't like writing PHP
 
lol
@NikiC Jut reading down into the depths of its internals?
 
@rlemon remember when I said yesterday the earth could be flat n they could be lying to us?
 
@LeviMorrison hm...
 
@NikiC My edits for SplDoublyLinkedList and such are now live! Horay!
 
6:20 PM
:)
You need to fix more :)
If you want to fix the whole SPL documentation, you need to work faster :P
 
@NikiC Hey man, I'm recently married, work two jobs, and go to a university part-time. I'm a busy guy!
 
@LeviMorrison respect for u!
 
@Nadal Thank you.
 
@LeviMorrison :)
(That was in response to the enthusiasm you had when you got the karma and me saying that it won't last long.)
 
At the moment I'm on IRC trying to figure out the proper way to document certain things.
Don't worry, I haven't lost it yet :)
 
6:31 PM
@LeviMorrison Great, that's all I wanted to hear :)
 
@NikiC I see you committed some stuff as well.
 
6:58 PM
@LeviMorrison btw, what happened to the PHP book thing?
Is that idea already dead?
 
@ircmaxell and @edorian weren't entirely keen on having me. But since @Gordon won't have much if any time to work on it, it seems dead.
So I began work on the Spl instead :)
Figured I may as well be useful in my little bit of spare time.
 
Sounds reasonable
 
@LeviMorrison It wasn't about keen on having you
 
7:14 PM
@ircmaxell Perhaps I generalized a bit much. I can definitely see why you would hesitate on including me in the project. I have no proof that I am bringing anything to the table.
And the project dying had little to do with me, I know.
 
well, or that you fit with our views (which means it's hard to know if you'd be a good fit)
 
@ircmaxell Do you think you will write an article on the Spl?
 
I've started
 
@ircmaxell I look forward to it :)
 
:-D
 
7:21 PM
what will it be about?
 
My thoughts on SPL (the good, the bad, and the retarted
 
@ircmaxell lol, well the documentation will fall into the latter part of it.
 
the good has only 2 or 4 items in it
the bad only has 2 or 4 items in it
 
Uh oh
retarded has a lot
 
the majority falls into the latter category... :-D
 
7:24 PM
Honestly, I'm not sure why SplStack uses a DLL. Aren't most implementations array based?
Although, arrays in PHP wouldn't get you much.
They're just as big as a DLL in terms of storage per unit.
probably.
 
@LeviMorrison SLL
 
@ircmaxell True. I do know of several array-based implementations, though. But a DLL seems very inefficient.
Also
SplStack lets you get stuff from anywhere on the stack
 
@LeviMorrison Sure, you could do array, but then you need to keep track of the top element separately
 
Can you say retardedd?
 
@LeviMorrison which defeats the point
IMHO, there should be only a few methods:
 
7:26 PM
@ircmaxell That's not true at all.
 
public function count()
public function pop()
public function push()
@LeviMorrison how is it not true
 
@ircmaxell Peek?
@ircmaxell In any kind of stack I've seen, you keep track of your size.
Well, in an array-based implementation, your last element is simply size-1.
and where to add is size itself.
 
@LeviMorrison nice, but not necessary
@LeviMorrison that's the same as keeping track of the top element
 
@ircmaxell I always do that. $stack + $stackPos
 
@ircmaxell Stacks with node implementations still have to keep track of the top node for performance reasons anyway.
 
7:31 PM
@LeviMorrison I usually prefer to just leave elements in place and maintain an explicit size. I don't like unset()ing (also it saves the count() call)
 
@LeviMorrison either way, you need to keep track of top node. By definition. But the difference is if you track the other way (which becomes a DLL)
 
@ircmaxell In any case, SplStack should not be a DLL. It is not a DLL. It's not even a SLL. It's a Stack.
Abstraction lost.
 
technically, a stack could just be:

typedef struct stack {
     stackEntry *top;
}
typedef struct stackEntry {
     stackEntry *prev;
     zval *zval;
}
 
True. But every implementation I've seen also has a size. It's useful to know.
 
@LeviMorrison You can implement a stack using a DLL. That's fine. It's just an implementation detail. The problem is that the API leaks that abstraction, which means that a stack === queue in therms of the api pushed out by api
@LeviMorrison Useful, but not necessary
In practice, I would include it. But at a minimum, you just need a pointer to the top entry of the stack, and then a pointer from each element to the one before it
 
7:37 PM
@ircmaxell Agreed. You said what I meant.
 
:-D
 
If I were writing a paper on the subject, I'd be more clear :)
 
Oh of course
 
@ircmaxell Couldn't you save you the top pointer though?
 
@NikiC I didn't even understand your sentence.
 
7:39 PM
@NikiC how would that work
 
like
typedef struct Stack {
    Stack *prev;
    zval *zval;
} stack;
@LeviMorrison I was wondering why one needs an explicit top pointer :)
 
@NikiC That's just a SLL
 
@ircmaxell yes :)
 
which in escessence is a stack based on the ordering of the link
 
Also, I'd like to have a stack know if it's empty. If I want to pop something, i don't want problems, you know?
 
7:41 PM
@LeviMorrison Oh sure. In practice it could (and likely would) have more. But not fully
 
What is the difference between a reverse linked list and a stack though? Isn't that basically the same
 
@NikiC Well, I was just doing that to exlempify what is passed to the application (the stack, not the stack entry)
 
^^
 
For a Stack API, I'd like:
push()
pop() //returns the value, curse you C++ STL!
peek();
size();
empty();
I don't think stacks should have iterators, personally. But if they did, it'd be top down, for sure.
 
@LeviMorrison size() & empty() could be replaced with count()
 
7:44 PM
@ircmaxell could be, yes. But often I like to know the size, and other times I just want to know if it's empty. I could write size() == 0, but the written semantic of .empty() is nice, in my opinion.
 
fair enough
 
I'm hoping I can improve the existing Spl without BC as much as possible, but all the while pushing for a rewrite somehow. Possibly by creating new classes. Simply dropping the Spl prefix, or better yet by namespacing it would work.
That way we can maintain the old without BC issues, but have the newer, better API.
 
"I like the idea of the Spl, but it was very poorly created." :(
 
It's a thought, at least.
@NikiC Well, it's true.
 
It's not that bad after all
It has it's quirks, yes
But at least parts of it (like Iterators) are very solid imho
 
7:50 PM
Forgive me, I meant the Spl datastructures, not the whole SPL.
 
ah, okay
then I might agree ;)
 
I mean whole SPL
 
^^
The PHP sucks mentality is coming back ^^
 
Iterators are ok. There's some interesting parts of it, but not bad as a whole
interfaces suck except for Countable and RecursiveIterator
 
@ircmaxell And the exceptions are a bit messy, but I've found some of them to be quite useful.
I like the proposed JsonSerializable too.
 
7:52 PM
Let's just blame everything on the development process :)
 
@NikiC lol, it's definitely part of the problem.
 
Good afternoon
 
It's probably the main part of the problem ;)
 
@LeviMorrison Exceptions is one that I'm actually fairly for
 
<label for="applyMonths_<?=$i?>"><input type="radio" name="period_<?=$i?>" value="0"<?=isset($_POST['period_' . $i]) ? ($_POST['period_' . $i] == 0 ? " checked=\"checked\"" : "") : ""?> />Apply to first <input type="text" name="applyMonths_<?=$i?>" id="applyMonths_<?=$i?>" class="applyMonths" maxlength="2" tabindex="<?=$tabIndex++?>" value="<?=isset($_POST['applyMonths_' . $i]) ? $_POST['applyMonths_' . $i] : ""?>" /> months</label>
ew
 
7:53 PM
@NikiC I don't blame anything
let's just try to clean it up instead
 
@ircmaxell And that leads us to the development process: We can't.
BC policy probably won't allow most of the changes.
 
@ircmaxell ircmaxell, I'm writing an RFC for Spl improvement. When I get to the part about suggesting improvements that break BC in the datastructures, would you like to help me define a better API?
 
Sure we can. Create a new \SPL namespace, and then add new stuff there, eventually deprecating the existing structures in favor of the new varient
@LeviMorrison Absolutely
 
@ircmaxell Exactly.
 
a little confusing at first, but that's a documentation problem
 
7:55 PM
@ircmaxell I'm not sure that this is going to happen.
 
@NikiC neither am I, but that's no excuse to not try
 
@ircmaxell Also, if we can get a good working example out in the wild, it's more likely to be absorbed.
The Spl started as an extension in the first place.
 
very much agreed
I'd start it as native PHP
then narrow down the API, and once that's done, move to pecl
and then once that's solid move in
 
@ircmaxell Agreed.
 
@ircmaxell THAT sounds good!
 
7:58 PM
So
 
let's get a github repo going, and then go from there
 
I would participate if you need help ;)
 
++
 
All in favor of SplDatastructures project, salute!
 
okay, will you open one @irc?
 
7:58 PM
/me salutes
 
@NikiC sure
 
@ircmaxell Honestly, I'd like to do it.
My github account is pretty darn skimpy :)
 

« first day (426 days earlier)      last day (4522 days later) »