Code Reiview for an PHP PDO Queries? is there a better way to do it? so this is my code for a equipping an item in my game dev't:    

try {
        $db = getConnection();

        $db-&gt;beginTransaction();

        $sql_chara_gold = $db-&gt;query("SELECT chara_gold FROM chara WHERE chara_id = $shop-&gt;chara_id");
        $get_chara_gold = $sql_chara_gold-&gt;fetchColumn();

        $sql_shop_price = $db-&gt;query("SELECT item_price FROM shop WHERE item_id = $shop-&gt;item_id");
        $get_shop_price = $sql_shop_price-&gt;fetchColumn();

        if($get_chara_gold &gt;= $get_shop_price){
            $sql_put_item = "INSERT INTO bag(chara_id, item_id, item_qty)
            VALUES(:id,:item_id,1) 
            ON DUPLICATE KEY 
            UPDATE item_qty = item_qty +1";

            $sql_set_gold = "UPDATE chara ch 
            INNER JOIN item it
            ON it.item_id = :item_id
            SET ch.chara_gold = ch.chara_gold - it.item_price 
            WHERE chara_id = :id";

            $sql_set_qty =  "UPDATE shop 
            SET item_qty = item_qty - 1 
            WHERE item_id = :item_id";


            $stmt = $db-&gt;prepare($sql_put_item);  
            $stmt-&gt;bindParam("id", $shop-&gt;chara_id);
            $stmt-&gt;bindParam("item_id", $shop-&gt;item_id);
            $stmt-&gt;execute();

            $stmt = $db-&gt;prepare($sql_set_gold);  
            $stmt-&gt;bindParam("id", $shop-&gt;chara_id);
            $stmt-&gt;bindParam("item_id", $shop-&gt;item_id);
            $stmt-&gt;execute();

            $stmt = $db-&gt;prepare($sql_set_qty);  
            $stmt-&gt;bindParam("item_id", $shop-&gt;item_id);
            $stmt-&gt;execute();

            $db-&gt;commit();

            $db = null;

            echo json_encode($shop); 
        }else{
            echo '{"error":{"text":'.json_encode($get_shop_price).'}}'; 
        }
I don't know if I'd use ORM for something so simple, but it may be something to look into. At the very least, you should get in the practice of escaping query parameters to avoid SQL injection. I often use Aura SQL for this, because it's dead simple: https://github.com/auraphp/Aura.Sql

An example query using Aura would look like this:

$user = $db-&gt;fetchOne('SELECT chara_gold FROM chara WHERE chara_id = :id', [
    'id' =&gt; $shop-&gt;chara_id
]);


Aura will automatically escape any bound parameters, like :id, so you don't have to worry about SQL injection. If you don't use Aura, at least use PDO::quote.

Funds transfer is the textbook example of why you need transactions to meet the ACID requirements, so it's good that you're using one, but I don't see your rollback. I assume this is in your catch clause which wasn't included.