The literal meaning of sqlt and mysqli

What does t stand for in sqlt?
What does i stand for in mysqli?

That’s just a variable name. It has no real hidden meaning to it. It all depends on your company and their naming conventions.

It stands for “improved”. Basically meaning that it’s a better version of mysql_* and supports OO unlike mysql_*. Also, mysql_* was removed back in 7.0 so the only support is mysqli_* and PDO.

Thank you very much.

So sqlt in the below as a whole means “calling SQL with desinated database connection in mysqli_query”.

Nope. The variable $sqlt has no real meaning to it. The whole mysqli_query($dbConnect, $sql); does. That part is just running the query using the current database connection. The variable $sqlt does nothing other than containing the returned result from the query being executed. You can then do something else with $sqlt if you wanted to after that. I mean, it doesn’t even have to be named $sqlt, it could be called $poop for all anyone cares. It’s just a variable that will contain the returned result.

1 Like

then, I like to write it as following.

$returnResult=mysqli_query($dbConnect, $sql);

Yes, you may call your variable whatever you like, but it’s always best to choose a name with meaning to represent what the varible actually is, so when you, or another looks at your code in the future, they can get a good idea of what that varialbe represents.

When the person who wrote that code named the variable $sqlt, the first part, sql obviously refers to “Structured Query Language”, so we know it’s to do with the database, but the t part is less obvious. It may have meant something to the person who wrote it (at the time they wrote it), but to us it’s a bit cryptic as to what it actually means.
Therefore it’s a good example of bad naming, we don’t understand the meaning of the name. The person who wrote it knew, but what about them returning to the code a year or two later, would they remember its meaning?

So give variables meaningful, non-cryptic names. You probably don’t want to be too verbose with names, but you can always add comments to your code to give hints as to what is what. Future you will be glad you did, but will curse you if you did not.

1 Like

My best guess is that the “t” is short for “test”.

$sql=“select * from test”;
$sqlt=mysqli_query($dbConnect, $sql);

IMHO, a few more characters eg. $sql_test or $test_query or $test_select etc. for the sake of readability would not have been excessive cost for the benefit of helping reduce uncertainty.

1 Like

I find the $sqlt misleading because it is far from being a SQL query string.

I would have named the query result something like: $oTest because if the query is successful then an Object is returned otherwise a bool FALSE (which goes again the grain, I would have preferred returning an empty Object).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.