CUTCODEDOWN
Minimalist Semantic Markup

Welcome Guest
Please Login or Register

If you have registered but not recieved your activation e-mail in a reasonable amount of time, or have issues with using the registration form, please use our Contact Form for assistance. Include both your username and the e-mail you tried to register with.

Author Topic: PDO Prepared Query within an Prepared query  (Read 1719 times)

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
PDO Prepared Query within an Prepared query
« on: 19 Jan 2020, 10:57:50 am »
Is doing this safe?

Code: [Select]
        // Create the (MOT Reminder) PDO Prepared Query:
$stmt1 = $DB->prepare("INSERT INTO wp_users (`user_email`, `user_registered`) VALUES ( :email, NOW())");
$stmt2 = $DB->prepare("INSERT INTO wp_mots (`mot_vrm`, `mot_expiry`, `mot_uid`, `mot_added`) VALUES ( :vrm, :expiry, :userid, NOW())");

$data1 = [ 'email' => "{$email}" ];

// Execute (MOT Reminder) Prepared Query:
$stmt1->execute($data1);

$data2 = [

':vrm' => strtolower($plate), ':expiry' => $expiry['system'], ':userid' => $DB->lastInsertId(),

];

    $stmt2->execute($data2);
$DB is literally the PDO PHP class - no wrappers ;)
For reference $DB is:
Code: [Select]
$host = 'localhost';
$db   = '[SNIP]';
$user = '[SNIP]'; // DO NOT USE ROOT...
$pass = '[SNIP]';
$charset = 'utf8mb4';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";

$options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ];

try {

     $DB = new PDO($dsn, $user, $pass, $options);

} catch (\PDOException $e) {
 
     throw new \PDOException($e->getMessage(), (int)$e->getCode());

}
« Last Edit: 19 Jan 2020, 11:01:28 am by GrumpyYoungMan »
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #1 on: 19 Jan 2020, 11:02:55 am »
I am sorry if I am making you pull your hair out Jason and others...
« Last Edit: 19 Jan 2020, 03:08:24 pm by GrumpyYoungMan »
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 1049
  • Karma: +188/-1
    • CutCodeDown -- Minimalist Semantic Markup
Re: PDO Prepared Query within an Prepared query
« Reply #2 on: 19 Jan 2020, 05:24:34 pm »
I don't see anything wrong with it that would make it unsafe... though I'd probably lose the "variables for nothing" that are $data1 and $data2, and some formatting wouldn't hurt.

You're also actually not doing anything that warrants putting them "out of order" like that.

... and for the love of christmas, stop doing derpy nonsense like this:

"{$email}"

It's just $email. I'd also axe the backticks as pointless and switch to single quoted strings. A wee bit o' formattin' wouldn't hurt matters much either.

Code: [Select]
$stmt = $DB->prepare('
INSERT INTO wp_users (
user_email, user_registered
) VALUES (
:email, NOW()
)
');
$stmt->execute([ 'email' => $email ]);

$stmt = $DB->prepare('
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
) VALUES (
:vrm, :expiry, :userid, NOW()
)
');
$stmt->execute([
':vrm' => strtolower($plate),
':expiry' => $expiry['system'],
':userid' => $DB->lastInsertId()
]);

This way you don't even need a separate $stmt for the second one.

But in terms of code security / safety, nothing wrong with what you posted... apart from the possibility of some values staying in memory unreleased at the current scope, one reason to get rid of any local variables you don't actually need.

Your connection method causes me more worries than the queries, with things like the login credentials stored in whatever scope you happen to be executing at. Hence why I would advise against having ANY of the variables you have in that code present even existing... but then I have no idea if you're in global scope or not and/or how/if you're passing around $DB securely.
We are all, we are all, we are all FRIENDS! For today we're all brothers, tonight we're all friends. Our moment of peace in a war that never ends.

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #3 on: 20 Jan 2020, 06:05:57 am »
I don't see anything wrong with it that would make it unsafe... though I'd probably lose the "variables for nothing" that are $data1 and $data2, and some formatting wouldn't hurt.

I am trying really hard to do that - and those few escaped me - every time I use a variable I think of you - do I actually need this to be a variable...

You're also actually not doing anything that warrants putting them "out of order" like that.

... and for the love of christmas, stop doing derpy nonsense like this:

"{$email}"

It's just $email. I'd also axe the backticks as pointless and switch to single quoted strings. A wee bit o' formattin' wouldn't hurt matters much either.

Code: [Select]
$stmt = $DB->prepare('
INSERT INTO wp_users (
user_email, user_registered
) VALUES (
:email, NOW()
)
');
$stmt->execute([ 'email' => $email ]);

$stmt = $DB->prepare('
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
) VALUES (
:vrm, :expiry, :userid, NOW()
)
');
$stmt->execute([
':vrm' => strtolower($plate),
':expiry' => $expiry['system'],
':userid' => $DB->lastInsertId()
]);

This way you don't even need a separate $stmt for the second one.
I didn't think about doing it that way... Ooops! Sorry! I'll remove the curly braces too and the backticks as for the formatting, I think some of it is lost as I post? But your formatting looks better and which is why you make money from this...
But in terms of code security / safety, nothing wrong with what you posted... apart from the possibility of some values staying in memory unreleased at the current scope, one reason to get rid of any local variables you don't actually need.

I am really pleased to hear that! :)

Your connection method causes me more worries than the queries, with things like the login credentials stored in whatever scope you happen to be executing at. Hence why I would advise against having ANY of the variables you have in that code present even existing... but then I have no idea if you're in global scope or not and/or how/if you're passing around $DB securely.
$DB is literally just the PHP PDO class - should I just connect inside the functions now?

If not how do you recommend to pass the database connection around?
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #4 on: 20 Jan 2020, 07:54:11 am »
The whole function - which may also explain why I prepared the queries outside of the loop!

Code: [Select]
function install_insert_reminders_and_clients_database() {

global $DB, $DISPLAY;

$ourPage = "";

// Client Insert Limit:
$limit = 20;

// Basically the file containing all the demo people names
require_once ROOT_PATH . "client_data.php";

// Table Row - Start Point.
$rowId = 1;

// Setup Alternating Plate Colours
$plateColors = [ 'white', 'yellow' ];
$plateColor = 0;

$ourPage .= "<h1>Create and Insert Demo Data</h1>\n";

$ourPage .= "<table border=\"1\">\n";

// What Type of number plate needs creating:
for( $i = 0; $i < $limit; $i++ ) {

require_once ROOT_PATH . "create_vrms.php";

$plate = create_vrm();

$date = mt_rand( strtotime("2018-01-01"), strtotime("2022-01-01") );
$expiry = [ 'human' => date("F jS Y", $date ), 'system' => date("Y-m-d", $date) ];

// Create a randon client:
$client = [

'first' => $people['first'][ mt_rand( 0, ( count( $people['first'] ) - 1 ) ) ],
'surname' => $people['surname'][ mt_rand( 0, ( count( $people['surname'] ) - 1 ) ) ],

];

// Create the client email address...
$email = "test_" . strtolower($client['surname']) . "." . strtolower($client['first']) . "@[SNIP].co.uk";

// All Client and VRM, MOT Information:
$clients_data[] = [

'client' => [ 'first' => $client['first'], 'surname' => $client['surname'], 'email' => $email ],
'vehicle' => [ 'vrm' => $plate, 'expiry' => [ 'human' => $expiry['human'], 'system' => $expiry['system'] ] ],

];

// Client Data:
// Execute (MOT Reminder) Prepared Query:

// Create the MOT Reminders & Word Press PDO Prepared Queries:
$stmt = $DB->prepare("
INSERT INTO wp_users (
user_email, user_registered
)
VALUES (
:email, NOW()
)"
);

$stmt->execute([ 'email' => "$email" ]);

$stmt = $DB->prepare("
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
)
VALUES (
:vrm, :expiry, :userid, NOW()
)");

// Reminder Data:
$stmt->execute( [
    ':vrm' => strtolower($plate),
    ':expiry' => $expiry['system'],
    ':userid' => $DB->lastInsertId()]

    );

}

It is just a way of inserting a load of demo data to test my WordPress project!
« Last Edit: 20 Jan 2020, 08:00:48 am by GrumpyYoungMan »
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 1049
  • Karma: +188/-1
    • CutCodeDown -- Minimalist Semantic Markup
Re: PDO Prepared Query within an Prepared query
« Reply #5 on: 20 Jan 2020, 08:26:53 am »
Well you didn't include the loop (now you did), but if you're going to prepare outside the loop, pre-bind so you only have to execute() inside the loop.

Cutting out all the unused code (which there's a LOT of) and simplifying the loop down:

Code: [Select]
function install_insert_reminders_and_clients_database() {

global $DB;

// Client Insert Limit:
$limit = 20;

// Basically the file containing all the demo people names
require_once(ROOT_PATH . 'client_data.php');

// Alternating Colours should be NONE of the server-side's bloody business!

$insertUser = $DB->prepare('
INSERT INTO wp_users (
user_email, user_registered
)
VALUES (
:email, NOW()
)
');

$insertUser->bindParam(':email', $email);

$insertMots = $DB->prepare('
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
)
VALUES (
:vrm, :expiry, :userid, NOW()
)
');

$insertMots->bindParam(':vrm', $plate);
$insertMots->bindParam(':expiry', $expires);
$insertMots->bindParam(':userid', $lastId);

// it's a once, why put it inside the loop?!?
require_once(ROOT_PATH . 'create_vrms.php');

do {

$email = 'test_' . strtolower($client['surname'] . '.' . $client['first']) . '@[SNIP].co.uk';
$insertUser->execute();

$plate = create_vrm();
$date = mt_rand(strtotime("2018-01-01"), strtotime("2022-01-01"));
$expires = data('Y-m-d', $date);
$lastId = $DB->lastInsertId();

$insertMots->execute();

} while (--$limit);

}

It's called POEM, prepare once, execute mostly... and it's VERY handy for cases where you're going to do the same query/queries over and over and over again inside a loop. Prepare, bind, then loop the execute with variables. In this case the function level scoping of the vars and the fact they only exist once and are bound to the query means a lot less overhead -- including axing the array -- inside the loop.

execute(Array) -- if you're doing it once.

bindParam / execute() -- if you're doing the same query a bunch of times.
« Last Edit: 20 Jan 2020, 08:29:35 am by Jason Knight »
We are all, we are all, we are all FRIENDS! For today we're all brothers, tonight we're all friends. Our moment of peace in a war that never ends.

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #6 on: 20 Jan 2020, 09:13:01 am »
Thank you - this is why you do it for a living and I don't!

Sorry, should I give up? as what you are saying is my code is rubbish... and I should stick to my day job?

How can I get the client to do the alternating row colours? Is through jQuery/ajax??

I have never used the do function...

Thanks again for the input - I appreciate and I am trying to learn!
« Last Edit: 20 Jan 2020, 09:19:34 am by GrumpyYoungMan »
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #7 on: 20 Jan 2020, 09:55:20 am »
Well you didn't include the loop (now you did), but if you're going to prepare outside the loop, pre-bind so you only have to execute() inside the loop.

Cutting out all the unused code (which there's a LOT of) and simplifying the loop down:

Code: [Select]
function install_insert_reminders_and_clients_database() {

global $DB;

// Client Insert Limit:
$limit = 20;

// Basically the file containing all the demo people names
require_once(ROOT_PATH . 'client_data.php');

// Alternating Colours should be NONE of the server-side's bloody business!

$insertUser = $DB->prepare('
INSERT INTO wp_users (
user_email, user_registered
)
VALUES (
:email, NOW()
)
');

$insertUser->bindParam(':email', $email);

$insertMots = $DB->prepare('
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
)
VALUES (
:vrm, :expiry, :userid, NOW()
)
');

$insertMots->bindParam(':vrm', $plate);
$insertMots->bindParam(':expiry', $expires);
$insertMots->bindParam(':userid', $lastId);

// it's a once, why put it inside the loop?!?
require_once(ROOT_PATH . 'create_vrms.php');

do {

$email = 'test_' . strtolower($client['surname'] . '.' . $client['first']) . '@[SNIP].co.uk';
$insertUser->execute();

$plate = create_vrm();
$date = mt_rand(strtotime("2018-01-01"), strtotime("2022-01-01"));
$expires = data('Y-m-d', $date);
$lastId = $DB->lastInsertId();

$insertMots->execute();

} while (--$limit);

}

It's called POEM, prepare once, execute mostly... and it's VERY handy for cases where you're going to do the same query/queries over and over and over again inside a loop. Prepare, bind, then loop the execute with variables. In this case the function level scoping of the vars and the fact they only exist once and are bound to the query means a lot less overhead -- including axing the array -- inside the loop.

execute(Array) -- if you're doing it once.

bindParam / execute() -- if you're doing the same query a bunch of times.

I didn't and can't condense it as much as you did but this is what I have so far:
Code: [Select]
function install_insert_reminders_and_clients_database() {

global $DB, $DISPLAY;

// Client Insert Limit:
$limit = 20;

// Basically the file containing all the demo people names
require_once ROOT_PATH . "create_client.php";

// Function for creating the random VRM:
require_once ROOT_PATH . "create_vrms.php";

// USER PDO Prepared Query:
$insertUser = $DB->prepare("
INSERT INTO wp_users (
user_email, user_registered
)
VALUES (
:email, NOW()
)"
);

// Reminder Data PDO Query:
$insertReminder = $DB->prepare("
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
)
VALUES (
:vrm, :expiry, :userid, NOW()
)"
);

do {

// CREATE the VRM:
  $plate = create_vrm();

// Create a random client:
$client = create_client();

// CREATE the expiry date:
$expiry = date("Y-m-d", mt_rand( strtotime("2019-01-01"), strtotime("2023-01-01") ));

// Create the client email address...
$email = "test_" . strtolower($client['surname']) . "." . strtolower($client['first']) . "@example.co.uk";

$insertUser->bindParam( 'email', $email );

$insertUser->execute();

$plate = strtolower($plate);
$lastId = $DB->lastInsertId();

    $insertReminder->bindParam( ':vrm', $plate );
    $insertReminder->bindParam( ':expiry', $expiry );
    $insertReminder->bindParam( ':userid', $lastId );
   
    $insertReminder->execute();

    // HTML Stuff - System Test:
    // All Client and VRM, MOT Information:
$clients_data[] = [

'client' => [ 'first' => $client['first'], 'surname' => $client['surname'], 'email' => $email ],
'vehicle' => [ 'vrm' => $plate, 'expiry' => $expiry ],

];

}
while (--$limit);

// HTML Stuff
$ourPage = "";

// Setup Alternating Plate Colours
$plateColors = [ 'white', 'yellow' ];
$plateColor = 0;

$ourPage .= "<h1>Create and Insert Demo Data</h1>

<table border=\"1\">\n";

// Table Row - Starting Row:
$rowId = 1;

foreach( $clients_data as $client_data ) {

$ourPage .= "<!-- Begin Row {$rowId} -->
<tr>

<td>

{$rowId}

</td>
<td>

<div style=\"border: solid 2px black; border-radius: 5px; width: 100px; padding: 5px; text-align: center; font-weight: bold; background: {$plateColors[$plateColor]}\">{$client_data['vehicle']['vrm']}</div>

</td>
<td>

<div>Client: {$client_data['client']['first']} {$client_data['client']['surname']}</div>
<div>Email: {$client_data['client']['email']}</div>
<div>Expiry: {$client_data['vehicle']['expiry']}</div>

</td>
<td>

{$rowId}

</td>

</tr>
<!-- End Row {$rowId} -->\n";

// Increment tbe Table Row count:
$rowId++;

// Alternator Plate Background color:
if( $plateColor == 1 ) { $plateColor = 0; } else { $plateColor = 1; }

}

// print_r($client_data);

$ourPage .= "</table>\n";

$DISPLAY->add_title("Insert Demo Data");

$DISPLAY->add_content($ourPage);

$DISPLAY->output();

}

It is still "bloated" as I still like to see what is going...

Thanks again for the feedback and assisting - I appreciate it and I want to learn to program cleaner code so I really do appreciate your help!
« Last Edit: 20 Jan 2020, 10:22:39 am by GrumpyYoungMan »
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 1049
  • Karma: +188/-1
    • CutCodeDown -- Minimalist Semantic Markup
Re: PDO Prepared Query within an Prepared query
« Reply #8 on: 21 Jan 2020, 05:53:57 pm »
First off, little tip... the more code you show from the start, the better the solution can be dialed in.

Next, again there is NO reason in modern code for colours to be set in the markup. In general 99.99% of the time you use style="" you're screwing things up as that's NONE of the server side code's business.

Next... I'm not 100% sold that's tabular data, at least not from how you're presenting it. If it is tabular data, those DIV should be TD and if you want the layout different from that, use flex or grid.

Next... don't waste memory and processing time copying stuff into an array when you could just output it! This is doubly silly since you're dumping it into an array then dumping your HTML into a string -- don't do that!

Hence something more like:

Code: [Select]
function install_insert_reminders_and_clients_database() {

global $DB, $DISPLAY;

// Client Insert Limit:
$limit = 20;

// Basically the file containing all the demo people names
require_once ROOT_PATH . "create_client.php";

// Function for creating the random VRM:
require_once ROOT_PATH . "create_vrms.php";

// USER PDO Prepared Query:
$insertUser = $DB->prepare("
INSERT INTO wp_users (
user_email, user_registered
)
VALUES (
:email, NOW()
)"
);

// Reminder Data PDO Query:
$insertReminder = $DB->prepare("
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
)
VALUES (
:vrm, :expiry, :userid, NOW()
)"
);

echo '
<table class="inserts">
<tbody>';

$insertCount = 0;

do {

  $plate = create_vrm();
$client = create_client();
$expiryDate = date("Y-m-d", mt_rand( strtotime("2019-01-01"), strtotime("2023-01-01") ));

// Create the client email address...
$email = 'test_' . strtolower($client['surname'] . '.' . $client['first']) . '@example.co.uk';

$insertUser->bindParam( 'email', $email );
$insertUser->execute();

$plate = strtolower($plate);
$lastId = $DB->lastInsertId();

$insertReminder->bindParam( ':vrm', $plate );
$insertReminder->bindParam( ':expiry', $expiry );
$insertReminder->bindParam( ':userid', $lastId );
    $insertReminder->execute();
   
    echp '
<tr>
<td>', ++$insertCountl, '</td>
<th scope="row"><div>', $plate, '</div></th>
<td>
',$client['firxt'], $client['surname'], '<br>
', $email, '<br>
', $expiry, '
</td>
</tr>';

} while (--$limit);

echo '
</tbody>
</table>';

}

Ditching that string addition mental midgetry... or if you are derping it into a string for that equally derpy looking "DISPLAY" object, still do it in this order rather than making that extra Array for nothing.
We are all, we are all, we are all FRIENDS! For today we're all brothers, tonight we're all friends. Our moment of peace in a war that never ends.

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #9 on: 22 Jan 2020, 01:34:12 am »
 
First off, little tip... the more code you show from the start, the better the solution can be dialed in.

Next, again there is NO reason in modern code for colours to be set in the markup. In general 99.99% of the time you use style="" you're screwing things up as that's NONE of the server side code's business.

Next... I'm not 100% sold that's tabular data, at least not from how you're presenting it. If it is tabular data, those DIV should be TD and if you want the layout different from that, use flex or grid.

Next... don't waste memory and processing time copying stuff into an array when you could just output it! This is doubly silly since you're dumping it into an array then dumping your HTML into a string -- don't do that!

Hence something more like:

Code: [Select]
function install_insert_reminders_and_clients_database() {

global $DB, $DISPLAY;

// Client Insert Limit:
$limit = 20;

// Basically the file containing all the demo people names
require_once ROOT_PATH . "create_client.php";

// Function for creating the random VRM:
require_once ROOT_PATH . "create_vrms.php";

// USER PDO Prepared Query:
$insertUser = $DB->prepare("
INSERT INTO wp_users (
user_email, user_registered
)
VALUES (
:email, NOW()
)"
);

// Reminder Data PDO Query:
$insertReminder = $DB->prepare("
INSERT INTO wp_mots (
mot_vrm, mot_expiry, mot_uid, mot_added
)
VALUES (
:vrm, :expiry, :userid, NOW()
)"
);

echo '
<table class="inserts">
<tbody>';

$insertCount = 0;

do {

  $plate = create_vrm();
$client = create_client();
$expiryDate = date("Y-m-d", mt_rand( strtotime("2019-01-01"), strtotime("2023-01-01") ));

// Create the client email address...
$email = 'test_' . strtolower($client['surname'] . '.' . $client['first']) . '@example.co.uk';

$insertUser->bindParam( 'email', $email );
$insertUser->execute();

$plate = strtolower($plate);
$lastId = $DB->lastInsertId();

$insertReminder->bindParam( ':vrm', $plate );
$insertReminder->bindParam( ':expiry', $expiry );
$insertReminder->bindParam( ':userid', $lastId );
    $insertReminder->execute();
   
    echp '
<tr>
<td>', ++$insertCountl, '</td>
<th scope="row"><div>', $plate, '</div></th>
<td>
',$client['firxt'], $client['surname'], '<br>
', $email, '<br>
', $expiry, '
</td>
</tr>';

} while (--$limit);

echo '
</tbody>
</table>';

}

Ditching that string addition mental midgetry... or if you are derping it into a string for that equally derpy looking "DISPLAY" object, still do it in this order rather than making that extra Array for nothing.
Thanks, I’ll take a look and make the changes!

I thought it was tabular data as it’s a VRM, name, email and an expiry date? But what do I know?

I am sorry, tell me if you want me to stop posting, or you could just ban me? I am just trying to learn as you can see I have made a lot of the changes you recommended!

As this is just a test demo system do u ever need to see it? It’s more so I know it’s working - but learn some lessons along the way?
« Last Edit: 22 Jan 2020, 01:42:50 am by GrumpyYoungMan »
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 1049
  • Karma: +188/-1
    • CutCodeDown -- Minimalist Semantic Markup
Re: PDO Prepared Query within an Prepared query
« Reply #10 on: 22 Jan 2020, 06:05:28 am »
I am sorry, tell me if you want me to stop posting, or you could just ban me? I am just trying to learn as you can see I have made a lot of the changes you recommended!
I would never tell someone to stop posting when asking GOOD questions. Important questions. That's what SMART people do is ask, listen. digest, then ask some more.

If I ever come across as harsh, it's a mix of disgust at seeing bad practices corrupting someone like yourself, and my belief that you -- or anyone -- can do all of this in a better, cleaner, more efficient way. It's a matter of willpower and learning, which is why I try to point out all the failings I can so you can get better.

Our industry has a ... problem with dishonestly so as not to "upset" anyone. The end result is people plodding on as if nothing is wrong, and in the end never actually learning anything. Worse, it results in lame excuses NOT to fix things and contributes to why so many people struggle and fail.

So when I push, shove, and get confrontational, it's because I believe in you.

So suck it up princess:


As I recently told a paying client's CTO, "I DON'T WANT A GOOD CODER! What I want is those men to have someone to look up to, someone they know will be there to pick them up if they fall. I've got eight weeks to teach these idiots what it took you twenty years to learn on the streets. Now if you can help them learn, if you can be that kind of good coder, then you will have a coding team that will save your ass in deployment. But you pull this lone wolf **** on me again, I will saddle you with such a maggoty ****** team that you are guaranteed to go out of business your first week!"

Amazingly he knew the reference.

... and I made these forums for the express purpose of people like you asking these sorts of questions. Be kind of silly to ban you for doing the one thing these forums are for!

As this is just a test demo system do u ever need to see it? It’s more so I know it’s working - but learn some lessons along the way?
I'm willing to take a look at anything... so long as you can handle the answers.
We are all, we are all, we are all FRIENDS! For today we're all brothers, tonight we're all friends. Our moment of peace in a war that never ends.

GrumpyYoungMan

  • Hero Member
  • *****
  • Posts: 787
  • Karma: +8/-0
    • Grumpy Young Man
Re: PDO Prepared Query within an Prepared query
« Reply #11 on: 22 Jan 2020, 08:34:20 am »
I am sorry, tell me if you want me to stop posting, or you could just ban me? I am just trying to learn as you can see I have made a lot of the changes you recommended!
I would never tell someone to stop posting when asking GOOD questions. Important questions. That's what SMART people do is ask, listen. digest, then ask some more.
Well you are doing this for a living, although I will probably never get that efficient I do like to do things my self and I am trying to learn - as can hopefully be seen as to the code changes I make? - I guess I am a jack of everything and a master of none...

If I ever come across as harsh, it's a mix of disgust at seeing bad practices corrupting someone like yourself, and my belief that you -- or anyone -- can do all of this in a better, cleaner, more efficient way. It's a matter of willpower and learning, which is why I try to point out all the failings I can so you can get better.
That's why I found you here - you made an impression on me from CF.

Our industry has a ... problem with dishonestly so as not to "upset" anyone. The end result is people plodding on as if nothing is wrong, and in the end never actually learning anything. Worse, it results in lame excuses NOT to fix things and contributes to why so many people struggle and fail.

So when I push, shove, and get confrontational, it's because I believe in you.

So suck it up princess:


As I recently told a paying client's CTO, "I DON'T WANT A GOOD CODER! What I want is those men to have someone to look up to, someone they know will be there to pick them up if they fall. I've got eight weeks to teach these idiots what it took you twenty years to learn on the streets. Now if you can help them learn, if you can be that kind of good coder, then you will have a coding team that will save your ass in deployment. But you pull this lone wolf **** on me again, I will saddle you with such a maggoty ****** team that you are guaranteed to go out of business your first week!"

Amazingly he knew the reference.

... and I made these forums for the express purpose of people like you asking these sorts of questions. Be kind of silly to ban you for doing the one thing these forums are for!

As this is just a test demo system do u ever need to see it? It’s more so I know it’s working - but learn some lessons along the way?
I'm willing to take a look at anything... so long as you can handle the answers.
Thanks, I'll keep on posting and yes I can handle your answers they are important as they will make me a better coder - so why shouldn't I be prepared to listen?

I guess the upside for you is you keep getting activity on these forums so you can grow... :)
Trying to learn a new trick to prove old dogs can learn new ones...

Total Novice have-a go Amateur Programmer - not sure that is the right thing to say... but trying to learn...

 

SMF spam blocked by CleanTalk

Advertisement