Msql conn and pdo_mysql conn may exist in the same file?

msql conn and pdo_mysql conn may exist in the same file? or conflict made?

			$conn->beginTransaction();		
			$conn->commit();
			$conn->rollBack();

what is the equivalent of these pdo in mysql?

1 Like

yes. just use different variables for differend instances of these classes.

1 Like

i HAVE FOUND THIS [I want mysql not msqli ] but is mysql CLI - I want in PHP program mysql transaction…???

http://php.net/manual/en/mysqli.begin-transaction.php

1 Like

By that do you mean MySQL the database, or that you want to write new code using the old and no-longer-part-of-current-PHP mysql functions such as mysql_query and so on? If the latter, why? I can see why many don’t have the luxury of time to replace existing working code until they have no choice, but why would you write new code that way?

1 Like

msql conn and pdo_mysql conn may exist in the same file?

Yes, they can.

However, mysql extension itself does not exist in recent PHP version, so you can use it only with outdated versions that will be eventually extinct.

$conn->beginTransaction();		
$conn->commit();
$conn->rollBack();

you can always run a genuine mysql query for that, using whatever API you are using

BEGIN TRANSACTION;
COMMIT;
ROLLBACK
1 Like

this is true even using PDO Transactions and coexist a mysql conn in an included file?

this is correct >>> ???


// trans.php
function begin(){
    mysql_query("BEGIN");
}

function commit(){
    mysql_query("COMMIT");
}

function rollback(){
    mysql_query("ROLLBACK");
}

as long as you are using the same API for all the queries involved in a transaction, it won’t do any harm.

But of course you cannot access a transaction started within one connection from another connection.

1 Like

if using UPDATE TABLE (not insert) in same page script when sometimes may create table lock… ? I having table lock sometimes…

mysql_query(“BEGIN TRANSACTION”); // this BOTH ARE CORRECT???

don’t use mysql_* functions! they are outright dangerous.

whether you have a table lock depends on the used DB engine. If there is, a transaction would hold the lock as long as it is active.

2 Likes

what you mean by “transaction”…? MYISAM tables locks depend on many big selects of 200 rows each?

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