On 27/3/23 09:52, Rohan McLeod via luv-main wrote:



My questions are:
-Is this a nighmare scenario ?

It could be because all businesses need means of control over their products. It would sensible for them to port all of their non-OS products to Linux and then craft a Gnome spin off too look exactly like windows type desktops. Then basically repackage debian or RH but with their apps and GUI.

If, however, they got deeply into kernel development then they could steer Linux in a way that extinguishes competition.....I vaguely remember them doing that before.


- A reason to celebrate ?


Definitely a win but I think we are all to old to care really. I'm guessing most of us have used Linux for over a decade as our core desktop. I think I moved a couple of years ago in about 1998.....that was a couple of years ago right?

Ironically I installed Edge last night to check out Bing AI to write a database abstraction layer for PHP PDO vs Chat-GPT

"Can you write me a PHP database abstration layer that uses Prepared statements for all database calls"

Bing AI - I can't do that.

Chat-GPT:

Sure! Here's an example of a PHP database abstraction layer that uses prepared statements for all database calls:


<?php

class Database {
  private $conn;

  public function __construct($servername, $username, $password, $dbname) {
    $this->conn = new mysqli($servername, $username, $password, $dbname);
    if ($this->conn->connect_error) {
      die("Connection failed: " . $this->conn->connect_error);
    }
  }

  public function prepare($sql) {
    return $this->conn->prepare($sql);
  }

  public function execute($stmt) {
    $stmt->execute();
    return $stmt->get_result();
  }

  public function query($sql, $params = []) {
    $stmt = $this->conn->prepare($sql);
    if (!$stmt) {
      die("Error preparing statement: " . $this->conn->error);
    }
    if (count($params) > 0) {
      $types = '';
      $args = [];
      foreach ($params as $param) {
        $types .= $this->get_type($param);
        $args[] = &$param;
      }
      array_unshift($args, $types);
      call_user_func_array([$stmt, 'bind_param'], $args);
    }
    $stmt->execute();
    $result = $stmt->get_result();
    if (!$result) {
      die("Error executing statement: " . $this->conn->error);
    }
    return $result;
  }

  public function get_type($var) {
    if (is_int($var)) {
      return 'i';
    } elseif (is_float($var)) {
      return 'd';
    } elseif (is_string($var)) {
      return 's';
    } else {
      return 'b';
    }
  }

  public function close() {
    $this->conn->close();
  }
}

?>

This database class takes four parameters in its constructor: the database server name, the database username, the database password, and the database name. It uses the mysqli extension to connect to the database.

The prepare() method is a simple wrapper around the mysqli::prepare() method.

The execute() method takes a prepared statement as its parameter, executes it, and returns the result set.

The query() method takes an SQL query string and an optional array of parameters as its parameters. It prepares the SQL statement using the mysqli::prepare() method, binds the parameters using the mysqli_stmt::bind_param() method, executes the statement using the mysqli_stmt::execute() method, retrieves the result set using the mysqli_stmt::get_result() method, and returns it.

The get_type() method is a helper method that determines the correct type for a given parameter based on its PHP type.

The close() method is a simple wrapper around the mysqli::close() method.

This database class uses prepared statements for all database calls, which helps prevent SQL injection attacks. By binding parameters to the prepared statement, the database can ensure that all user input is properly sanitized before it is executed.

~~~~~~~~~~~~~~~~~~~

The code itself is OK-ish and more of a wrapper in most parts but my point is that if MS was so up to date with software then I would have expected the same type of responses. Perhaps MS needs Linux far more that we can appreciate. Given the transition from cmd to "Power Shell" to a Linux command system to porting leading products MS SQL Server, Edge, etc) perhaps we are seeing Linux becoming the new Windows.

As for lower tools like disk/print/network managers why bother? Just use the existing ones.

Mainstream users won't notice because they don't care. It would probably be the biggest task for MS pressuring hardware vendors to re-release drivers that were Linux capable from the ground up or contributing their secret sauce to Open driver projects (which would of course let their competition know how they did what and potentially sacrifice their innovations to competitors [idle speculation as not my area of knowledge]).

Cheers

Piers


_______________________________________________
luv-main mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to