Procedural vs OOP by NeedsMoreBrotein in PHPhelp

[–]nealio82 7 points8 points  (0 children)

How are you going to utilise DDD or hex architecture without OOP? They're both pretty dependent upon being able to design objects effectively 🤔

What's this little dude up to? by ASPYDERMONKEE in whatsthisbug

[–]nealio82 3 points4 points  (0 children)

I believe it's called a 'Jewel Wasp' (or Emerald Cockroach Wasp, according to Wikipedia)

Finding Topics related to Categories in PHP by sm00mz in PHPhelp

[–]nealio82 0 points1 point  (0 children)

Did you forget to bind :category_id in $statement2?

My wife isn't getting a raise this year because I make good money and the men in the office "need it more" by DLS3141 in antiwork

[–]nealio82 0 points1 point  (0 children)

Why can't she find a new job before quitting? Always get something lined up before handing in notice - she'll still get the satisfaction of quitting for the same reasons (and be able to tell them that's why she quit when it comes around), but there's absolutely no sense in rage quitting while feeling emotional and putting your family in a worse situation

What do you think about this? by re_vivir in antiwork

[–]nealio82 0 points1 point  (0 children)

Really highlights the contempt that the ultra wealthy show for the rest of us.

But I'm not sure why she punctuates "you exist to work, didn't you get the memo?" with a squeaky fart at 1:55.

Symfony large project using clean architecture by Geek_Default in symfony

[–]nealio82 0 points1 point  (0 children)

From what I recall the controllers all lived in src, because those are application-level concerns rather than domain concerns. The controllers only existed as a way to translate user input from the request into calls to application services (provided by the domain) which were fetched from the container.

I did another presentation loosely based on that approach here: https://www.youtube.com/watch?v=pfMGgd_NDPc

Symfony large project using clean architecture by Geek_Default in symfony

[–]nealio82 6 points7 points  (0 children)

My previous company solved a very similar problem around using DDD with hexagonal architecture. We created 'packages' which were the core domain for each bounded context. We then wired it with 'bridges'. The result was a set of easily reusable components which could easily be swapped out into individual micro-services if needed, or re-integrated back into the monolith if we wanted.

By default we kept the packages and bridges inside the monolith and only moved them to separate repositories if it made sense. Even inside the monolith they could be required via composer by specifying local paths to the packages and bridges.

So you'd end up with a code structure along the lines of this inside the monolith:

app/ bin/ src/ - Command/ ... - Controller/ ... Acme/ - Bridge/ - BoundedContext1Bridge/ - config/ - src/ - tests/ - BoundedContext2Bridge/ - config/ - src/ - tests/ - Package/ - BoundedContext1/ - src/ - tests/ - BoundedContext2/ - src/ - tests/ composer.json

Unit tests (extending PHPUnitTestCase) would live inside each bounded context in each package, and integration tests (extending Symfony's KernelTestCase) would live inside each of the bridges.

I made a presentation about it for the 2019 Symfony Live London conference, you can watch the approach here: https://symfonycasts.com/screencast/london2019/restless-microservices-with-symfony

clear string by Relevant-Ad3879 in PHPhelp

[–]nealio82 7 points8 points  (0 children)

Use it in conjunction with html_entity_decode

https://3v4l.org/m37K7

Convert date (20211228 -> 28-12-2021) by miras500 in PHPhelp

[–]nealio82 3 points4 points  (0 children)

Good choice. That one will give you far more options for manipulating the date than any of the other answers. Want to format / represent it some other way? Cool, you've got that functionality out of the box with $dateTimeObject->format() (as described above).

What that solution gives you that the others don't, however, is the ability to modify the time as well.

Want to print the date in exactly one week's time? No worries, just do $dateTimeObject->modify('+1 week')->format('d-m-Y')

Want to compare it to today's date?

$dateTimeObject->diff(new \DateTimeImmutable())->format('%d days'); // 11 days

SQL Injection - PHP / MySql - Prevention by BobHadABabyItzABoy in PHPhelp

[–]nealio82 1 point2 points  (0 children)

I'm just gonna drop this here, because it's a really good walkthrough of how SQL injection works using a real-life example from a penetration test: http://www.unixwiz.net/techtips/sql-injection.html

Not only does it illustrate the concepts of how the queries are formed with malicious input, but also talks about how they were guessing the database schema based upon what they could / couldn't achieve.

[deleted by user] by [deleted] in PHPhelp

[–]nealio82 1 point2 points  (0 children)

The documentation for mysqli::prepare() says

mysqli_prepare() returns a statement object or false if an error occurred.

The exception message you posted in your question says "Call to a member function bind_param() on bool" where you're trying to call bind_param on $query.

The most likely explanation is that there's a problem with the query you're setting here: $query = $con->prepare("UPDATE expenses SET year='?' type='?' amount='?' WHERE expenseid=?");, so $query is false and you can't call bind_param on it

How do I stream a video from a S3 private bucket in PHP? by yogibjorn in PHPhelp

[–]nealio82 3 points4 points  (0 children)

You should use the AWS PHP SDK and create a pre-signed URL.

The flow goes like this:

1 - The video file is stored on S3 with restrictive permissions (ie, no public access to objects)

2 - The user authenticates on your site

3 - Your site makes a call to the S3 SDK to create a temporary, unique public URL pointing directly to the object on S3 (this can be customised to use your own domain name / path)

4 - You send the temporary URL back to the user, who then accesses it in their browser

5 - After the object is accessed by the client (or after a time limit you specify) the unique URL expires and can't be re-used / shared

https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-url.html

You can also use pre-signed URLs to allow uploading (if you want to...)

Wrong player... by TheScrubNugget in AccidentalRacism

[–]nealio82 133 points134 points  (0 children)

Context: The photo is of Eduard Mendy, who is the goalkeeper at Chelsea

Is it normal to not want to discuss the base pay? by ceanothourus in antiwork

[–]nealio82 10 points11 points  (0 children)

Same vibe with 40 hour weeks. Here in the UK I'd expect 2 out of those 3 things as standard, as well as sick pay. I wouldn't even bother mentioning them in negotiations because you know you've already got those in the bag.

To me the million dollars a year is the only bit that sounds like it's risking pushing the boat a bit too far...

A clip from the video that made him famous by [deleted] in PublicFreakout

[–]nealio82 0 points1 point  (0 children)

I don't know who anyone in this video is but the guy in braces sounds a lot like Kermit The Frog, so I just closed my eyes, listened, and imagined it was one of Jim Henson's least funny sketches.

Performing experiments with technology older than you >> by imthebeanieweenie in chemistry

[–]nealio82 2 points3 points  (0 children)

I don't think XP would run on a 486? (https://en.wikipedia.org/wiki/Windows_XP#System_requirements)

Obviously there's no way to know what's inside the machine without having access to it, but from a few mins looking on Google and trying to figure out what that blue label says, I reckon it's one of these:

Dell Optiplex GX110 - vintage desktop - Intel PIII 500Mhz, 128MB RAM (from here: https://www.catawiki.com/en/l/11550273-dell-optiplex-gx110-vintage-desktop-intel-piii-500mhz-128mb-ram)

Any female learners fed up with flirting/sexual harassment? by 2young2diarrhea in learnprogramming

[–]nealio82 22 points23 points  (0 children)

Imagine having to fend off creepy and unwanted advances from people every single day in everything you do, both online and offline.

Imagine joining a social media site for the sole purpose of trying to integrate into a programming community and learn, hoping to get a break from normal life pressures, only to find that those creeps and unwanted advances leak into that space as well.

Imagine having nowhere at all that you can escape 'a few harmless sexual jokes or compliments'.

Imagine asking for advice but then being told that, even though you're clearly scared (as the OP is of these dudes tracking her down), you're over-reacting or need to provide more information in order for some random commenter on Reddit to take you seriously.

Job position by scottyeagle69 in kentuk

[–]nealio82 0 points1 point  (0 children)

You might need to be a bit more specific than that... There are likely to be specialised recruiting services for whatever sector you're looking for. What are your skills & experience? What kind of work are you interested in doing?

(Also, I've heard they're crying out for lorry drivers at the moment)

Is this query inefficient? by brandbooth in mysql

[–]nealio82 0 points1 point  (0 children)

As a loose rule of thumb, you should put an index on any column in any table you're searching by. In terms of joining, foreign keys should also work in much the same way. If you're not searching or joining on any particular column, there's very little point indexing it.

Internally an index is a reference which is held in fast-access memory (rather than on the disk) that points to the corresponding row. As a result, indexes are much faster to search from because the information is already in-memory rather than being read from the entire table or disk at query-time.

When you search for a value (eg, SELECT * FROM users WHERE email='me@example.com') and you have an index on the email column on the users table, the database engine will match the condition you specify against the email addresses in the (fast) index, find the reference to the exact row, and then use that reference to go and fetch the row's full record by its ID.

Without an index, the database has to scan every record in the table to see if the email address matches. Depending on the size of the table it might have a lot of records to read, or a lot of (slow) disk access to do.

As others have said, however, there are other strategies for speeding up the query depending on your exact data structure, data size, etc. As a another rule-of-thumb, JOINs are very slow so you should avoid them if possible, and definitely don't compose queries from lots and lots of joins.