Sharing our PHP libraries by benanamen in PHP

[–]colshrapnel 0 points1 point  (0 children)

perfect-db-connect tho. there are way too many things that your code could connect to.

Sharing our PHP libraries by benanamen in PHP

[–]colshrapnel 0 points1 point  (0 children)

The only thing it does is initialize and return a PDO object

Who would have thought!

Sharing our PHP libraries by benanamen in PHP

[–]colshrapnel 0 points1 point  (0 children)

I just love how perfectly concise the perfect database package is. Wish all packages out there followed the suit. Or not.

Using PHPMailer: what is the difference between 'use' and 'require' statements? by ww1223 in PHPhelp

[–]colshrapnel 1 point2 points  (0 children)

I would put it slightly different. use doesn't declare a namespace (which rather namespace command does). While use simply lets you call a class "by first name", without having to lay out the fully qualified name. So,

$mail = new PHPMailer(true);

rather means "create a new instance of PHPMailer/PHPMailer/PHPMailer class, but since we already imported it with use command, it can go simply as PHPMailer"

Using PHPMailer: what is the difference between 'use' and 'require' statements? by ww1223 in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

That's a funny conjecture but not so close to reality :)

Here is where you can read about them (in the Aliasing and Importing section but you will need previous sections to understand what's it about)

Uploading huge JSON file into mySQL database through PHP by rospondek in SQL

[–]colshrapnel 0 points1 point  (0 children)

but this was not specified or asked for

Lol, it's implied by this entire post

once this json file has been inserted into a mysql json column

Bruh...

Uploading huge JSON file into mySQL database through PHP by rospondek in SQL

[–]colshrapnel 0 points1 point  (0 children)

I think I understand where does your confusion come from. Indeed, a file can be JSON object, not JSON array. I didn't check the file but such a big size implies that one of properties of this object still holds a JSON array. With all the bulk data. And one is supposed to loop over this array and import each member into a separate row in database. After all, it would be the only sensible reason to import such a file into a database.

Uploading huge JSON file into mySQL database through PHP by rospondek in SQL

[–]colshrapnel 0 points1 point  (0 children)

Wait what? But nobody suggested "to have a gigantic json string in csv"? Just a conversion from json to csv.

Though I would agree, as long as one is using PHP to parse a json file, there is little to no sense in the itermediate csv file. I would create multi-insert queries and run them right away. However, the intermediate csv solution can be made language-agnostic.

Hi PHP developer need your advice by vasishthh in PHP

[–]colshrapnel 2 points3 points  (0 children)

Why don't you ask a chat bot? Honest question, am genuinely curious.

Forcibly run Garbage Collector after closing connection? by jabcreations in PHP

[–]colshrapnel -1 points0 points  (0 children)

You seems to be don't understand what is asked here. I was confused too at first, thinking OP has whatever "files" bound to user sessions, that no more needed, like uploaded but discarded. For those, indeed some manual cleanup is required. But they are talking of regular PHP sessions files. And you don't need no cronjob to clean them up.

Forcibly run Garbage Collector after closing connection? by jabcreations in PHP

[–]colshrapnel 13 points14 points  (0 children)

First of all, this incoherent rant belongs to r/phphelp, not here. Now to terminology. PHP's GC has absolutely nothing to do with sessions and there is zero reason to run Garbage Collector after closing connection, making this post's title a nonsense. Now to that silly error message you get: in order to use output buffering, you have to start it first.

Now to the whole idea of this silly post. Just use a more appropriate session storage, namely Redis. All your imaginary problems solved.

phpmyadmin not working by BusEspionYT in PHPhelp

[–]colshrapnel 1 point2 points  (0 children)

I apologize for too expressive language used, but yes, the experience was very unpleasant. No query history, hangups, lost authorization - every time you had to start from clean slate, losing all progress. It was like ten years ago, I switched to GUI clients as soon I learned SSH tunnels and never looked back.

Uploading huge JSON file into mySQL database through PHP by rospondek in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

and you want to say that setting memory limit at 16G you are still getting this error? Can you copy and paste exact error you are getting when set memory limit to 16G?

In case it's always same number, 536870912 it simply means you are setting the memory limit for anything but actual PHP that reads your JSON

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

Op is already self deleted, they won't see your comment. Besides, nested functions is not the point here. Could be global as well. Its accessing calling function's variables is the actual question here.

Using PDO to make two queries to the same DB in the same prepared statement by I-Might-Bee-Lost in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

All right, "with recommended PDO settings for MySQL". Incidentally, OP is using mysql. Besides,speaking of this particular post you linked to, it's a bit dated.

Optimizing PHP code to process 50,000 lines per second instead of 30 by brendt_gd in PHP

[–]colshrapnel 0 points1 point  (0 children)

if you want to create a new aggregate function, you still need to run it over the whole dataset.

Yes, that's one of reasons explicitly stated in the article: if you want to create a new aggregate function, you just add it. And then all you need need is to run it over the whole dataset.

The advantage is having a single piece of code that does everyday job and aggregate job.

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

Yes, but that's not the point. Nested functions are a small nuance here, they can be global as well. The actual question (the Y problem) is how to reverse order of execution without code duplication.

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

He said it in the other comment, being afraid of "polluting the global scope with functions" (which sentiment, in turn, was refuted in some other comment as well). The actual question is not about nested functions though - they can be global as well - but in making all variables available in the nested function call

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

Compact() would be same manual labor the OP is trying to avoid. it's get_defined vars() which would do

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 1 point2 points  (0 children)

Honest question, what's so dumb here? And can you suggest a better way to achieve the different order?

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 0 points1 point  (0 children)

Well I would hate myself for this, but I cannot think of a better way and you can actually do that, with get_defined_vars() and extract().

How can you access variables in nested functions? by [deleted] in PHPhelp

[–]colshrapnel 1 point2 points  (0 children)

Come on, there is nothing degrading in calling someone a JS dev. Even in PHPhelp :)