snipped
I like that! I like that a lot. Thanks Kabal
OOP is something I really need to start doing, I am just struggling to think of things in a Object manner and before I know it I have a begin middle end approach.
South Africa’s biggest forum. Discuss, discover, and connect with thousands of members.
snipped
no problem
a simple way is to try internalise the Single Responsibility Principal, and always ask yourself things like "Does this really belong here? What is this doing, is this a good name? etc"
That's what I thought.
/moving on.
If this was production and not done in a few minutes of course I would do something like:
PHP:DELIMITER $$ CREATE PROCEDURE GetItem() BEGIN SELECT * FROM items; END$$
and then
PHP:$sql = 'CALL GetItem()';
Extra S in the second one:
private static GET_ITEMS_SQL = "SELECT * FROM items";
private static GET_ITEMS_SQL = "SELECT * FROM items WHERE id = ?";
should be:
private static GET_ITEMS_SQL = "SELECT * FROM items";
private static GET_ITEM_SQL = "SELECT * FROM items WHERE id = ?";
via Imgflip Meme GeneratorBecause this was not a project this was an illustration to the OP of the logical process that must happen for him to display the data and was in no way more than this.Why would you have completely different, insecure code in dev that will HAVE to change for it to be in production? Link some of your projects I'm (((interested)))
I think many miss that point; explanations are best kept simple.Because this was not a project this was an illustration to the OP of the logical process that must happen for him to display the data and was in no way more than this.
You should never fall into the quagmire of trying to envisage eveything as objects; that part of OOP is long considered BS. Design should be kept simple, don't ever build structure you'll probably never need.I like that! I like that a lot. Thanks Kabal
OOP is something I really need to start doing, I am just struggling to think of things in a Object manner and before I know it I have a begin middle end approach.
[)roi(];18691682 said:You should never fall into the quagmire of trying to envisage eveything as objects; that part of OOP is long considered BS. Design should be kept simple, don't ever build structure you'll probably never need.
SQL injection FTW
$stmt = $pdo->prepare('SELECT * FROM items WHERE id = :id');
$stmt->execute(array('id' => $id));
foreach ($stmt as $row) {
// do something with $row
}
Was a suggestion for Thor187; your code was spot on.this is true.
that is why I didn't go crazy and use a full blown service repository "pattern". all I wanted to do was create a simple abstraction/separation, to make things easier, in my mind, to understand, and potentially expand on if required
I'm finding it hard to implement this...I think this because of the modal. my uri is http://localhost:8080/places.php#more when it pops up. I think I'll need some javascript to fix this?
Why would you create a stored procedure for a simple select. I'd rather have it in code where it's more readable.