CodeIgniter Forums
[Fixed]Transaction problem - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: [Fixed]Transaction problem (/showthread.php?tid=20079)

[Fixed]Transaction problem - El Forum - 06-27-2009

Fixed the table of the InnoDB database has to be

Hi, I have been trying to use a transaction operation. But because there is no work, because if the second query, it comes out false, the first does not return to its previous value. With the false, the rollback does not occur.

Already in the first table that reduces the amount, and no one receives this amount

The Controller:

class stock extends Controller{
   function stock(){

function test(){
          $this->db->where('pid', $pid);
          $this->db->where('local', $delocal);
          $this->db->where('pid', $pid2);
          $this->db->where('local', $alocal);
           foreach ($q1->result() as $row){$dcta=$row->cta;}
           foreach ($q2->result() as $row){$acta=$row->cta;}

$this->db->query("UPDATE `asoc`.`pos_stock` SET `cta` = $dacta WHERE `pos_stock`.`pid` =$pid AND

$this->db->query("UPDATE `asoc`.`pos_stock` SET `cta` = $aacta WHERE `pos_stock`.`pid` =$pid AND
`pos_stock`.`local`=$aDlocal"); //I put the wrong name of "local"
                                //to see what happened if there was a failure

          $this->db->where('pid', $pid);
          $this->db->where('local', $delocal);
          $this->db->where('pid', $pid);
          $this->db->where('local', $alocal);
          $this->load->view('ts', $datos);



And the view

foreach ($qw4->result() as $row) {
echo $prc."===>";
foreach ($qw3->result() as $row) {
echo $pprc;


And here is the mysql code:
-- phpMyAdmin SQL Dump
-- version
-- Servidor: localhost
-- Tiempo de generación: 27-06-2009 a las 17:07:20
-- Versión del servidor: 5.0.67
-- Versión de PHP: 5.2.6-2ubuntu4.2


-- Base de datos: `asoc`

-- --------------------------------------------------------

-- Estructura de tabla para la tabla `pos_stock`

  `pid` int(11) NOT NULL,
  `cta` varchar(255) NOT NULL,
  `local` varchar(255) NOT NULL,
  `hora` time NOT NULL,
  `fecha` date NOT NULL

-- Volcar la base de datos para la tabla `pos_stock`

INSERT INTO `pos_stock` (`pid`, `cta`, `local`, `hora`, `fecha`) VALUES
(109, '64', '', '00:00:00', '0000-00-00'),
(110, '830', '1', '00:00:00', '0000-00-00'),
(110, '978', '2', '00:00:00', '0000-00-00');

I have tried to use $this->db->trans_start(TRUE) , but still failing.

If anyone can help me, I would greatly appreciate

[Fixed]Transaction problem - El Forum - 06-27-2009

Go'm an idiot, so much time on it and thought I had forgotten to change the table to InnoDB >.<

sorry, if they can delete the post, but may serve if someone else commits the same error