Jump to content

Objects, Classes, Variables, Libraries and Functions


LeonLatex

Recommended Posts

When it comes to MySQL objects, classes, variables, libraries, and functions, it is one of these that is pre-set/predetermined/developed, so there is something I misunderstand. This applies to the four different mentioned above, so it is one of the above mentioned that MySQL AB has pre-developed, so it is only to call up, this pre-made/ready to use....thing....😂 if you understand what I mean? If you understand what I mean then my question is: Where can I find a complete list, an overview of "what I am looking for"? I tried the PHP Reference Manual on php.net, but I did not find it there. I googled and searched, but I cannot find such an overview anywhere. Getting an answer to this would help me a lot in moving forward in my study of POD. Maybe this question sounds stupid, but it's the best way I can ask in English.

Link to comment
Share on other sites

MySQL AB was (past tense, currently owned by Oracle) the original developer of the MySQL database server, which implements their own variation of the Structured Query Language (SQL.)

i am guessing your post above is asking about the documentation for MySQL? that can be found at https://dev.mysql.com/doc/refman/8.0/en/ . the most relevant sections for the SQL they implement would be in 13.2 Data Manipulation Statements, for SELECT, INSERT, UPDATE, and occasionally DELETE queries. other often used sections in the documentation are sections 9 - 12 language structure, character sets, collations, unicode, data types, and operators and functions.

the SQL language that MySQL implements has nothing directly to do with php or the php extension (mysqli or PDO) you use. MySQL is a database server. Php is functioning as a client program, connecting to that server. after making a connection to the database server, you are building and sending SQL query statements to the server, retrieving, and using the result from the queries.

the php database extension (mysqli or PDO) is just the means you are using within the php code to interact with the MySQL database server.

Link to comment
Share on other sites

9 hours ago, LeonLatex said:

Then you can't help me.

 

Yes, you can help me. Actually, I looked at my question when I woke up this morning. So I just tried to be sarcastic back to my face. Because I saw how lame and stupid I can be when I'm tired and desperate to manage things.

So please give me a couple of hours and I will reformulate my question so it is at least can do it understandable and not make me sound so stupid. So, please, bear over with me one more time, and please forgive me.. I'll be back later this night (Norwegian time) 🙂 So sorry, requinix. I was just sarcastic to myself. I was so fed up 😐 

Link to comment
Share on other sites

requinix and mac_gyver
What I look for is an overview / an indexed list of .... e.g. in "new PDO refer to in PDO. What does PDO refer to?" O "in PDO stands for" object "(possibly I am wrong now and there is no such thing as pre-developed" object ". Struggling to find out what they are called / do not remember ) Is there a list of the objects (or the word/category i a'am looking for) that have been developed / made by MySQL AB? Did this get any clearer?

...or I think mac_gyver i into it in hes ansver above. Got to read that once more.

 

 

Link to comment
Share on other sites

the PDO documentation section in the php.net manual https://www.php.net/manual/en/book.pdo.php is what you are looking for.

the PDO acronym stands for PHP Data Objects and is found in the Introduction section.

the most relevant, commonly used sections to learn first are -

  1. PDO constructor - makes a connection
  2. PDO query - executes a non-prepared query
  3. PDO prepare - prepare a prepared query
  4. PDO lastInsertid - gets the last insert id from an insert/update query
  5. PDOStatement execute - executes a prepared query
  6. PDOStatement various fetch methods - fetch, fetchAll, fetchColumn - fetches data from a select query
  7. PDOStatement rowCount - gets the number of affected rows from an insert/update/delete query
  8. PDOException - used when handling user recoverable errors in your application

when you make the database connection using PDO, you should -

  1. set the character set to match your database tables, so that no character conversion occurs over the connection.
  2. set the error mode to use exceptions (i think i saw recently that this is the default now, but set it anyways.) the connection already always uses exceptions. the simplest application code will result if you also use exceptions for all the other statements that can fail - query, prepare, and execute and only attempt to handle exceptions in your code in the case of user recoverable errors, such as inserting/updating duplicate or out of range values.
  3. set emulated prepared queries to false, you want to use real prepared queries.
  4. set the default fetch mode to assoc, so that you don't have to specify it in each fetch statement.

see the following post for typical connection code (end of the post) and converging a non-prepared query to a prepared query - 

 

 

 

Link to comment
Share on other sites

also, i think you are getting stuck on the form (words, appearance) and you are not getting to the function (meaning, usage.) you don't actually need to fully understand OOP or the whole PDO extension in order to use it.

in your previous thread, i gave list of simple steps on converting existing mysqli based code to use the PDO extension. assuming that you understand what the mysqli code is doing now, this should almost be a no-think exercise.

typical prepared query msyqli code, with a multi-row result set -

$sql = "some sql query statement containing ? palace-holders for each value";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('s', $some_string_value);
$stmt->execute();
$result = $stmt->get_result(); // error now, because get_result depends on the mysqlnd driver

// at the point of producing the output
foreach($result as $row)
{
	// use elements in $row here...
}

after converting to use the PDO extension -

$sql = "some sql query statement containing ? palace-holders for each value";
$stmt = $pdo->prepare($sql);
$stmt->execute([$some_string_value]);
$result = $stmt->fetchAll(); // for a multi-row result set, you will typically WANT to fetch all the data at once, so that you can test, couunt, and loop over it as needed

// at the point of producing the output
foreach($result as $row)
{
	// use elements in $row here...
}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.