« first day (773 days earlier)      last day (4174 days later) » 

9:00 AM
47
A: How to get ID of the last updated row in MySQL?

PomykI've found an answer to this problem :) SET @update_id := 0; UPDATE some_table SET row = 'value', id = (SELECT @update_id := id) WHERE some_other_row = 'blah' LIMIT 1; SELECT @update_id; EDIT by aefxx This technique can be further expanded to retrieve the ID of every row affected by an updat...

 
Have you tried LAST_INSERT_ID(total + 1) ?
 
what about this one?
(just googling, ignore if you already tried it)
 
@Jack what would that accomplish ?
 
@tereško Yeah, I was just wondering about that myself heh
 
@FlorianMargaine this is where the query above comes from
 
9:05 AM
@tereško Hmm, LAST_INSERT_ID(owner_id) should work; after the query runs, you get the value from $db->lastInsertId()
 
> PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'owner_id' in 'field list' in ..
this is the message that i get
the owner_id is primary key
 
Right, and ip is unique?
 
yes
on duplicate it has to update the counter
 
understood .. hmm, pondering
 
I have php string, the string first line contain the header and others line contain data. eg.. id name address /n 1 KKK LLLL /n 2 www james .
 
9:06 AM
this is first part of transaction
 
I want to create associative array from this string.
 
the @update_id is later used in different select
 
How can I?
to encode as json
any one who can help me, I can do it using getcsv, but that is from file. and I want to done it using string.
 
@tereško Well, I would say UPDATE ..., owner_id = LAST_INSERT_ID(owner_id); set @update_id := LAST_INSERT_ID();
 
@abdulwakeel str_getcsv, json_encode?
 
9:13 AM
@abdulwakeel use php://memory' and use fgetcsv()`
 
@Jack that would be harmful
 
@tereško I wouldn't know how, but it sure ain't very pretty.
How would it be harmful, besides for the eyes?
 
owner_id is the primary key
 
I can do like that with simple explode, but I want to create associative array eg mysql table fetch
 
@tereško So? We're not changing that
 
9:16 AM
hmm ...
 
@abdulwakeel array_combine, str_getcsv, json_encode?
 
Uhm, why are you assuming his format is a CSV?
 
omg, it works , @Jack
 
@tereško welcome to the dark side =D
 
The report is in a tab-delimited format, with a header row containing all the fields listed in
the ‘Order’ report (detailed above) and a row for each order awaiting Dispatch, starting with the
oldest first.
 
9:23 AM
well, not really that dark ... just another shade of gray
 
the alternative was to use a columns with ON UPDATE CURRENT_TIMESTAMP , and find the latest update using that
your version is much cleaner
i think i actually saw it in mysql man pages , but the descriptiong was too muddled for my (lol) 27h uptime brain
 
human brains are not made for that kind of uptime
 
@abdulwakeel Use a global regex. Done.
preg_match_all
 
brain is not the issue ... main issue is the eyes
my FOV has dropped significantly , the irises are expanded at this stage , which causes the peripheral vision (which is more light/movement sensitive) to become constantly dazzled
 
And the regex would look like: /((.+))\t(.+))\n/
 
9:27 AM
@tereško stressing for deadline?
 
yeah
 
thanks @Christian , Warning: preg_match_all(): Compilation failed: unmatched parentheses at offset 12
 
@abdulwakeel Look, I can hint at some possible code.
It's up to you to understand it and get it working.
 
ok no problem
 
@Christian Yeh, sure that syntax error is intentional... :-P
Morning people
 
9:31 AM
@DaveRandom Intentional? Man, I'm not a PHP virtual machine, ok? :D
 
@tereško speaking of dazzled peripheral vision, I recently had a scintillating scotoma, now that's bizarre stuff .. goes away relatively quickly though.
 
This should work: /(([^\t]*)\t([^\t]*))\r?/g
preg_match_all('/(([^\\t]*)\\t([^\\t]*))\\r?', $input, $matches)
 
@Jack lol the Wikipedia page has pictures on it. That's one seriously clever camera...
 
I'm sure there's a more elegant approach; mine is hard coded to work with two columns.
 
ok, I am trying
 
9:36 AM
@Christian Looks remarkably like whatever you are doing, fgetcsv() is the tool for the job.
 
good mornings
 
@DaveRandom Isn't getcsv limited to commas though?
 
@Christian Nope. Has a whole bunch of extra args (delimiter, enclosure etc)
@hakre Good morning sir.
 
Nope, fgetcsv() is like MacGyver, multi purpose.
 
Ohh. @abdulwakeel Use McGiverTool .... I mean str_getcsv
 
9:38 AM
let me try
 
But I still think the regex approach is better. It's certainly more l33t looking. :D
 
I would rather use strtok()
 
morning all
 
@Jack Who came up with that function anyway? I'd rather have $tokens = strtok($html, 'xml'); or something of the sort.
 
str_getcsv work fine, create an array of only 1 row. contain all.
 
9:42 AM
@Christian I guess you haven't been around C code much :) it's the tool for tokenizing strings and I still use it in PHP for certain operations.
 
preg_match_all create array row from each column.
 
@Jack C? You should know I hate C.
 
I need some thing like key pair for json. eg order.status
 
@Christian Thou shalt respect the C; besides, many functions from PHP are based on stuff you'd find in glibc.
 
@abdulwakeel Assuming you have an array of arrays, like this: $lines = [[col1, col2], [cell1, cell2], [cell3, cell4]]
 
9:45 AM
yes, first line is heading and all other line data
 
user1125394
yea php is nothing but a C wrapper (jk)
 
$csvData = <<<CSV
Make\tModel\tNote
Chevy\t1500\tloaded
Chevy\t2500\t
Chevy\t\tloaded
CSV;

$path = 'data://text/plain,' . $csvData;
$file = new SplFileObject($path);
$file->setFlags(SplFileObject::READ_CSV);
$file->setCsvControl("\t");

foreach($file as $i => $row) {
    printf("#%d: %s\n", $i, implode(', ', $row));
}
 
hehe lovely
 
If your first line contains the field-names and you want to have them like a fetch assoc with database data, then please see:
3
A: PHP - Process CSV Into Array With Column Headings For Key

hakrePHP offers already 99,9% of what you need within SplFileObject, you add the missing 0,1% by extending from it. In the following example CSVFile extends from it: $csv = new CSVFile('../data/test.csv'); foreach ($csv as $line) { var_dump($line); } With your example data: array(3) { ["Mak...

 
not quick enough :D
 
9:48 AM
And in case you need more flexibility because of more type of CSV sources that differ (alpha code):
 
@hakre speaking of which, when's splFileObject getting binary support? I mean, other than ->fgetc() it's not terribly useful.
 
thanks
$csvData = <<<CSV
Make\tModel\tNote
Chevy\t1500\tloaded
Chevy\t2500\t
Chevy\t\tloaded
CSV;

$path = 'data://text/plain,' . $csvData;
$file = new SplFileObject($path);
$file->setFlags(SplFileObject::READ_CSV);
$file->setCsvControl("\t");

foreach($file as $i => $row) {
printf("#%d: %s\n", $i, implode(', ', $row));
} this code also work as seperater for each line.
 
@hakre Hey, have you had any answers on your phar russian doll situation? :)
 
@Jack Well the one at the very beginning. But it's not yet satisfying. But I guess PHP internals need to be changed for that.
 
What situation is this? :)
nested pharchives?
 
9:52 AM
My best hunch is that you basically can't apply the same wrapper twice on the same file descriptor.
@Leigh correct!
 
hey guys, i know this would be an old fashioned question for you but its important for me, can you please help me choose tool for development development of a high traffic website ? Choices are Custom PHP, Codeigniter, YII and Symphony.. I would appreciate your help..thanx
 
@Leigh Yes, the phar:// stream wrapper somehow stops at first (or was it last?) .pharextension found in the URI.
 
I found phar to be pretty evil internally, hooks everything.
 
Idea of phar is still nice though.
 
12
Q: How to place a phar file inside a phar file?

hakreI'd like to place a phar file inside a phar file. I tried it most straight forward: $p = new Phar('test.phar', null, 'self.phar'); $p->setStub('<?php Phar::mapPhar(); include \'phar://self.phar/index.php\'; __HALT_COMPILER(); ?>'); $p['index.php'] = '<?php echo "hello world\n";'; $p...

 
9:54 AM
@hakre When I get some free time (rare), maybe I'll trace through it in an IDE debugger
 
Thing is, it can find the phar (the error is different if it weren't there) ... so it could just complain about the stream wrapper being called twice on the same fd.
Trawling the source code didn't bring me very far though, it's pretty extensive
 
@Leigh That's an idea, indeed. I wonder on which computer I placed that test-code. In any case, for the moment I've noted in my book it's just a fairly bad idea to consider putting phar inside phar.
 
hmm, hmm hmm hmm, do you have a phar inside a phar I can download? :p
Or, out of interest, what happens if you include 'phar://phar://test2.phar/test.phar'
You can chain stream wrappers, I know that from using zlib:// and http://
 
user1607528
I have been locked to ask questions, what i can i do?
 
user1607528
its been a mistake
 
9:59 AM
@Muhammet Ask better questions
 
user1607528
@Leigh it is because i was using proxy
 
user1607528
i am not gonna use it again if they unlock me
 
@Muhammet Probably because several your questions got closed in quick succession
 
user1607528
i dont think so
 
user1607528
what can i do now
 
10:02 AM
And this morning I've just learned what a phar file is and a little on how it works, having never seen it before. Fantastic :)
 
That's the good thing about SO, even the seasoned developer learns something occasionally :) recently found out about MultipleIterator ... so much fun that!
 
user1607528
How to do this: Parent_category : child_c1 , Parent_category:child_c2
 
user1607528
I want it : Parent_category: child_c1, child_c2
 
user1607528
public function all_categories(){
$sql = "SELECT *
FROM categories AS c
LEFT JOIN sub_categories AS s
ON c.category_id = s.parent_id
ORDER BY c.category_name";
$stmt = $this->db->prepare($sql);
$stmt->execute();
while($row = $stmt->fetch()){
$rows[] = $row;
}
return $rows;
}
 
People talk about parents and children here so much, you'd think this was a parent-teacher conference.
 
user1607528
10:08 AM
please help, i stuck in this for 2 hours :(
 
user1607528
Currently it returns : Electronics : Phone, Electronics : Tv | I want Electronics : Phone,Tv
 
Hmm, it's easier in SQL to become your own grandfather than in real life, less stigmatizing basically.
 
Here's a quick q, PHP MVC best practice - models aren't just for database data, correct? Say I'm scanning a directory for files and their attributes, then performing a few sort functions on this data: I could have a file model representing the data retrieved, or would you just throw it in the controller?
Trying to follow FMSC though
 
@Leigh hmm, I tested many permutations, but not sure if I tested that one :)
 
models deal with your domain objects, which may or may not reside in a database.
 
10:14 AM
I was searching for the code, and didn't find it yet.
A database is just an awful place to store models in. I know better places :)
 
user1607528
How do i unlock my account to ask questions again?
 
@Muhammet ask on meta perhaps?
 
@Jack That's what I thought. And as files will be domain objects, a model to represent this should be good
 
@Jimbo models represent your data, so yeah do that stuff in the model. Generally, I try and keep controllers as light as possible, all the heavy lifting should be done in models or libraries
 
Yep fat models skinny controllers :) Cheers
 
10:18 AM
@hakre The 2nd error is because it is looking for a file called "test.phar/index.php", not treating test.phar as a container, either literally looking for a single file with that name (imagine the "/" is escaped), or treating test.phar as a directory
 
Ah I found the code, will test it now.
// Warning: include(phar://phar://test2.phar/test.phar): failed to open stream:
// phar error: no directory in "phar://phar://test2.phar/test.phar", must have at
// least phar://phar://test2.phar/test.phar/ for root directory (always use full
// path to a new phar)
include('phar://phar://test2.phar/test.phar');
This is giving a phar error then, so phar at least speaks to me ;)
It's just that phar ignores itself.
 
The ultimate obfuscation: passwords are stored in 6 layers of phar.
 
@hakre I'm sure I missed the explanation since it's such an obvious question, but... why?
 
10:34 AM
is there something wrong here ?
`SELECT data_student.name names,ozekimessagein.msg  msgs
FROM ozekimessagein
INNER JOIN data_student
ON ozekimessagein.sender=data_student.sender
ORDER BY names`
 
@rdlowrey There speaks a man who has never used Java. "You will write OOP code, and you will do it the way we tell you to. If you have a problem with that we invite you to piss off and go find another language."
 
nothing wrong ?
 
@peter If it's complaining, it may not like the alias in the ORDER BY clause (I can never remember what the rules are). Try ORDER BY data_student.name instead. Also consider aliasing the tables for $readability++;
 
10:39 AM
Don't you need 'FROM ozekimessagein, data_student
'
?
 
@Jimbo Implicit joins == :-(
(IMHO)
 
@Jimbo it will be right in inner join to make FROM two tables?
 
Hmm, would it be considered strange if I apply observer pattern to some of my models? Like, I have an accounting model that needs to get updated whenever something is sold, refunded or when a user upgraded his application to one for which we need to pay money and therefore it needs to be recorded.
I figured that my other models don't care about updating accounting information; instead they would just fire events whenever something interesting happens.
 
@peter No, it's alternative way of doing joins, it effectively does a CROSS JOIN IIRC
 
@DaveRandom so i must do it like jimbo said ? 'FROM ozekimessagein, data_student
 
10:44 AM
@peter it was a quick guess - perhaps you should try it?
run it on command line and see if it outputs what you want
 
@Jack I dont like Observer because of the implementation details it forces onto the objects. I'd probably go with a Decorator, e.g. new SaleEventListener(new Account); - this would delegate all calls to the Account instance and do something when the call is a sellFoo
 
@Gordon It intercepts the method calls, is that what you're saying?
 
@peter I would do this:
SELECT s.name AS names, o.msg AS msgs
FROM ozekimessagein o
INNER JOIN data_student s
  ON o.sender = s.sender
ORDER BY s.name
 
@DaveRandom Much prettier :)
 
@DaveRandom thx
 
10:50 AM
@Gordon I guess the problem is that it depends on two separate models, one handles application provisioning (and would therefore know about application usage) and the other handles purchasing ... a single decorator would therefore be impractical i guess.
 
@DaveRandom Why I care about that? I'm fiddling with fixing / testing PHP_CodeCoverage and run over an issue with phar files. When digging into phars then, I ran over this. So it's about finding the end of loose ends.
 
@peter If that doesn't get results you want, please explain what you do want, preferably with an accompanying sqlfiddle.com
 
@Jack yes, it intercepts the method calls
@Jack i dont understand what you mean. sorry.
 
meh
simple queries are simple
@Jack "model" is the whole layer
 
@hakre Fair enough, a) I'm nosy and b) whenever I see people archiving archives I have a gut "Your Doing It Wrong™" reaction (although I sure you are already well aware of that). If phar://phar:// doesn't work I'm thinking nasty work arounds using a custom stream wrapper class, but I'm sure there must be a simpler/prettier solution.
 
10:54 AM
unless you have a milti-headed app , you will have only one model
 
@tereško hmm ... I segmented it based on specific areas; not sure if that was the greatest idea :)
 
people hate me
Well, that's not really an answer indeed I'd say — Matthieu 1 min ago
 
@tereško would you rather have them to indifferent? which is worse to you?
 
Lol, feel free to ™ that @DaveRandom - I'll have "You're Doing It Wrong™" :P
 
i have been up programming for 12+ hours , since 22:00 or so ... at this point i prefer people which make me food , because in this timespan i was "eaten" 3 beers and pack of chips
 
10:58 AM
@Jimbo
 
Is the Mysql Database the Domain or how are the models domain models? — hakre 30 secs ago
@hakre you are drunk ... or asleep
 
@tereško Or both? Or any of these?
 
Do not return array of data, return data you can iterate over. — hakre 33 secs ago
arrays can be iterated
 
As NikiC found out yesterday, not really. At least not with the Iterator Pattern and the build in IteratorObjects.
 
@hakre .. slowly ... step away from the computar
 
11:05 AM
@tereško You only want me to fetch you a new beer from the fridge.
 
11:24 AM
DaveRando Hi.
how to retrieve pdf format file from database
 
@srinu Might need header("Content-type: application/pdf"); when fetching the pdf
& displaying it
 
can u give small example plz?
 
@srinu he just did
 
@srinu You're far better off storing your PDF files on disk - and referencing their location in a db
@srinu However if you MUST do this, you're looking for MEDIUMBLOB probably. This old post may help : php-mysql-tutorial.com/wikis/mysql-tutorials/…
 
@jimbo: Ok.
 
11:47 AM
@Jimbo i tried what ever link u have suggested to me.
but i download empty document.
 
Actually, storing documents in database ain't that bad; there's an inherent advantage to knowing that if the record exists, the document is there .. something that separated files doesn't give you.
 
@Jack What about file_exists()
or is_readable(), if you prefer
 
@Jack Yes, but how hard is if (!is_file($path)) { header('HTTP/1.1 404 Not Found'); exit('This server sucks!'); }?
 
user1125394
you need some webscaled nosql document-oriented database
 
My point is that; db record exists doesn't always mean file is there ... imagine your server crashes and you have salvaged a backup of your db ... worthless!
 
11:53 AM
He clearly will have no idea what you just said @cyril
 
@jimbo i am using this code.<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
defined('C5_EXECUTE') or die('Access denied');
$db=Loader::db();
if(isset($_GET['data_id']))
{
$id = $_GET['data_id'];
$query = "SELECT title,type,data " .
"FROM document WHERE id = '$id'";
$result=$db->Execute($query);
list($title,$type,$data) = $result->FetchRow();
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$title");
 
@Jimbo 99% of the the time, is_file()/is_dir() over file_exists(). More often than not you know what it should be, it avoids you doing things like fopen()ing a directory etc.
Plus it's less typing and I'm lazy.
 
@DaveRandom I suggested is_readable() - I know that's the one I use more often than is_file()
But obviously this is for php includes and things
 
The one thing I do like about separate files is that it lends itself well for x-sendfile :)
 
@Jimbo I tend not to bother with is_readable() because it doesn't account for e.g. other processes having a lock on the file. You still have to handle potential read errors, so I figure why bother? Unless you want to provide debug messages that tell you exactly where in the code it failed.
 
11:59 AM
@DaveRandom Fair point, but it could be that the PHP process is not allowed to read a certain file (no read permission), but it might still exist...
 
@Jimbo No arguments there, it's just a question of what you will do with that information. If you application wants to report the fact that the file exists, has permissions that allow it to be read, but still couldn't be read, then go for it. If you only want to report that the file "is a directory or doesn't exist", is_file() it. If you want to report that... and so on and so on. Nothing wrong with is_readable(), I just rarely require that kind of detail in my error logs/reports.
 
Gordan:i am trying to download document from database,its downloading empty file.
can u plz see my post above i posted.
give me solution.
 
@srinu my name is Gordon not Gordan.
 
sorry.
 
@srinu as for "give me solution", please see slash7.com/2006/12/22/vampires
 
@Gordon Thanks, I starred that as 'interesting'
 
12:43 PM
@hakre ping
 
@hakre I haven't managed to find a sensible way to make a phar take its data from a string, so it seems impossible. I had a nice regex parse out all the component parts, and was thinking of looping through them, creating phars from the data I read in, but ... no phar from string
 
long polling versus short polling... which is more db intensive? also long polling keeps locking up my Chrome dev tools... short polling did not
 
12:52 PM
Go on then, what is "cv-pls"
 
yesterday, by PeeHaa
cv-pls: Backlog (mirror) | Meaning | Chrome/Firefox Addon | Cat Content | Snippets: Mysql | Reference: Errors | Operators
 
Mornings after a while.
 
hola
 
@PeeHaa Ty
 
I don't think @hakre likes me any more :'(
 
12:58 PM
@DaveRandom probably doesn't recognise you since your picture changed ;)
 
Slightly , also : Is there a way to store part of your local copy of a git repo in a different location? Say I want to store one specific directory from the repo at a specific location? I feel sure I'm just being an idiot but I can't work out how to do it.
 
@DaveRandom ln ? :)
 
@Leigh Nah, he's just realised what a hateful person I am. Or maybe he's busy.
@Leigh - I think I need to go back to bed. Thanks.
 
it may not even work, just my first instinct
 
lol
It will work for what I am doing here.
 
1:02 PM
A more general solution is probably submodules
 
@Leigh Yeh but it's someone else's project, I just need to stuff from one specific directory which is self contained. They should probably make it a submodule, but I want to be able to update from their master so I'll just live with a symlink.
 
1:24 PM
Morning all
 
@ThiefMaster Just as we discussed it yesterday: theregister.co.uk/2012/11/27/oxbridge_kent_ddos_suspect - Although he probably did all the other stuff, they added "refusal to hand over crypto keys" to the list.
 
@DaveRandom Some variation of git archive
 
@Gordon It's too localised in my opinion, while the problem is probably common, the question probably won't be found by people with that problem
 
hey quick Q on type hinting, is it ok to type hint string params?
 
@AdamLynch How will you do that?
 
I've:
public function functionName(\string $param){...}
 
@Leigh i've already cv-ed it. will happily delv it when its closed
 
1:51 PM
Musn't be possible since PHPUnit complains:

ErrorException : Catchable Fatal Error: Argument 2 passed to functionName() must be an instance of string, string given,
 
@AdamLynch do you have a class called "string" in your root namespace?
 
@DaveRandom pong
@DaveRandom No, phone call.
 
@Leigh Not that I know of. Unless it's a Symfony2 thing (doubt it)
lemme check
I don't see anything
but PHPStorm seems to be resolving it
 
@AdamLynch There is no "string" type to be hinted, unless you create a class called "string"
 
hmm found the declaration
an empty String class
in testParserAcceptsStringAsClassName.php
answers my Q anyway
 
2:05 PM
@hakre Hey hey. Just had cause to revisit the ridiculous Excel/COM stuff I was doing a while ago and I recall you suggested you had done stuff with it before, and I had a question which I have now forgotten. Although, related, have you ever had any issues with colours coming out wrong when specified via COM? When I set a colour through the UI, read it a write it back to another cell it goes from my nice light blue to BLUE! (like #0000FF)
 
I did not experience exactly that, however what I know from windows, that are probably different color values.
how do you convert the values?
 
@hakre I am literally reading the value from one cell, via COM, and writing it back to another cell, via COM, in the same application, performing no operations on the value in between. It's really annoying me now. Although that link looks useful and may hold the answer somewhere, tnx
 
@DaveRandom signed integer values maybe. Something like that.
 
2:21 PM
@hakre You may have hit on something there actually, if I use colours with a value of <2.14E9 it works. Apparently VBScript doesn't support int64. Yet another win for MS.
 
use negative values then, maybe?
 
@hakre S'all good, I have a fairly decent handle on how to handle overflowed ints on 32-bit after all the messing around I have done with IP addresses. Not so much in VB but I know what needs to be done, I'm sure I can work out how to do it.
 
@DaveRandom A question for you, how would you do a random spinning like this Upload [Your Photos|a Photo Now|a Photo] > Upload Your Photos in JS. Match brackets, explode values, and select 0 to length? Thanks.
 
2:37 PM
@webarto Sorry? I don't quite follow, can you ellobrate
strVar.replace(/upload (?:your|a) photos? (?:now)?/ig, 'Upload Your Photos');
^^ like that? Or something totally else?
 
var str = 'Upload [Your Photos|a Photo Now|a Photo]';

str.replace(/\[(.*?)\]/g, function(match)
            {
            return match.explode('|')[rand(0, length)];
            });
not valid JS code but I hope you get it :P
so result would be e.g. Upload a Photo Now
@DaveRandom
 
2:54 PM
var str = 'Upload [Your Photos|a Photo Now|a Photo]';

str.replace(/\[(.*?)\]/g, function(match, opts) {
     function rand(min, max) {
         return Math.floor(Math.random() * (max - min + 1)) + min;
     }
     opts = opts.split('|');
     return opts[rand(0, opts.length - 1)];
});
@webarto ^^
Not that different from your code, you just have to use split() instead of explode(), provide your own rand() implementation (courtesy of MDN) and use the second arg of the callback to get the capture group.
 
var str = 'Upload [Your Photos|a Photo Now|a Photo]';

str = str.replace(/\[(.*?)\]/g, function(match)
            {
              match = match.split('|');
              return match[ Math.floor(Math.random() * (match.length - 1)) ];
            });

console.log(str);
xD (not working btw)
@DaveRandom awesome, thank you very much!
 
3:34 PM
@webarto What was that screenshot tool you use?
 
@MikeB Hyperdesktop (imgur) or PokIt.org
 
Thx, windows only?
 
Any way to propagate ini_set('display_errors', 1) through all included files? Or do I have to put this on every page? (Without editing php.ini, obviously).
 
@Jimbo Assuming you never set it again you should only need it once
 
Hmm, well it's not doing what it should do then
 
3:39 PM
You can verify with ini_get('display_errors') in the included files
 
Hmm, it's not being passed through to my controllers
Custom MVC, all requests routed through index.php (which has the ini_set()) using .htaccess - and files are included depending on controller / actions passed through in URL. Following pages don't return '' when checking ini_get('display_errors')
Pretty standard setup really
I mean they do* return '' when checking ini_get
 
var_dump(ini_get('display_errors'));
 
Yep that's what I did :)
String ''
 
I think PHP should really get built-in routing system and get rid of the url<=>filesystem mapping most sites currently use...
 
And if you put the same debug statement right after the ini_set call does it return true or 1?
 
3:43 PM
it's a shame how many big sites still have .php and query strings in their urls
 
Returns 1, so it's working in index.php
When including the controller from there, and putting this in __construct(), it doesn't return anything
 
@ThiefMaster It'd be nice to have that portability built-into php.. right now you essentially code to a web-server when you start using rewrite rules
 
Oh my god, I suck so hard. Just looking at some code I wrote 3 months ago and it is completely
 
@Jimbo So the problem lies somewhere between the two ini_get statements :p
 
@MikeB Yeah.. hold on
Does it propagate through require_once() ? That's what I'm using, not include()
 
3:46 PM
@MikeB: Yeah that's basically what I meant with the routing system. A simple way to map URL paths to callables. mod_rewrite is a huge mess IMO. And so is having your sourcecode in a folder within the document root
 
@Jimbo ini_set() propagates through all code executed in the scope of the currently running script. That's everything include/required, all functions, all classes, everything. If you set it somewhere in the script and it's not set later on, you unset it somewhere.
...or you didn't set it in the first place/the place where you set it hasn't been reached yet.
 
@DaveRandom I know, it should be a pretty straightforward bit of routing, reason I asked was because it's weird that it's not doing what I thought it should do... Will do a bit of tracing...
 
@ThiefMaster facebook/home.php :)
 
Placing that in __autoload() function returns '' too, perhaps this is the issue?
 
@Jimbo what if you do ini_set('display_errors', 1); var_dump(ini_get('display_errors')); on teh very first line of the script?
 
3:52 PM
And i can tie my shoes. It is very easy.... — Neal 2 mins ago
 
@DaveRandom :P
 
^_^
 
@DaveRandom Weird! So the only difference is five lines or so of code... requiring a config file, then doing a check on DEV_ENVIRONMENT (from config file). If it == 'dev', then set error reporting on.
@DaveRandom Fixed it anyway, cheers :)
 
Can anyone help me understand the comments here: stackoverflow.com/a/13587917/561731 ?
 
He's saying you shouldn't bother with date/time questions in php because they've all been asked :p
 
3:57 PM
@Neal lol
 
@Jimbo I have no idea what he is saying...
 
Is necessary?
 
@MikeB pffft
@MikeB haha i ddnt notice that
PURGED!
 
A lot of people take a long time to get their heads around date functions in PHP
To be honest, I know it took me a little longer than it should have
 
Where is the difficulty?
 
3:59 PM
@Meds In learning it
 
0
Q: Burninate [php-date]

amanaP lanaC A nalP A naM AI believe that php-date should be burninated. I serves no perpose as these questions are usually tagged with php and some date-time tag.

@MikeB ^
 
hey all, I am stuck at this. I am setting a session variable $_SESSION['code'] = $code; and redirecting the user to a page from where he will be redirected back to my page. And when I check the session variable again, it says undefined index. What could be wrong?

I do have session_start() at the top of the page.
 
4:16 PM
Here's a good one. if(call_user_func('class','method')) { //Get return value into variable } - Is that even possible?
 
@Jimbo Winner :-)
 
Callback on php.net...
 
I think he's missing one pair of parenthesis inside call_user_func() then it would be valid. Unless he really has a function called 'class' and his argument is 'method'
 
That was me changing the class and method names for ease of description ;)
 
if(call_user_func(array($object,'method'))) { //Get return value into variable }
is the same as
if ($object->method) { ... }
 
4:21 PM
Yep
 
posted on November 27, 2012 by Derick Rethans

Mongo is dead, long live MongoClient London, UK Tuesday, November 27th 2012, 15:09 GMT This afternoon we published version 1.3.0 of the MongoDB PHP driver. Besides a number of bug fixes since RC2 and RC3, this new release also includes a new MongoClient class. This new MongoClient class serves as a replacement for the Mongo class. T

 
Actually I think what he wants is $result = call_user_func(); echo $result; but in this sort of format if($result == call_user_func()) { echo $result; ) } // ie if call_user_func doesn't return false, put it into $result and do something with it
Btw the latter was just pseudo, not real code
 
Who is he?
 
user895378
@Jack I think Observer is useless in all but the most trivial contexts. IMHO injecting an even mediator instance into the domain entity is preferable to a decorator. And actually, since you're probably trying to notify other objects when CRUD actions happen, you'd be better served to move the save/delete/etc. actions out of the domain entities and into a gateway or data mapper object. I'd inject the mediator instance into the mappers to broadcast notifications to interested objects as needed.
 
user895378
4:46 PM
If you decorate every single entity object that needs broadcast capabilities you'll end up with two classes for every entity in the model ... which is totally unnecessary and a source of significant clutter. Instead, create a centralized event mediator and inject that as a dependency into each domain entity for which notifications are required.
 
user895378
Unless you only have one or two classes in your entire application that need to broadcast or receive notifications, of course. In that case (the extremely trivial scenario for which Observer is actually appropriate), a decorator is fine.
 
@Gordon iirc vimtutor doesn't teach you much. Only basic usage. Not any of those awesome vim magic tricks ^^
 

« first day (773 days earlier)      last day (4174 days later) »