luvas2010 / rapyd-framework

Automatically exported from code.google.com/p/rapyd-framework
0 stars 0 forks source link

6, database table is locked, UPDATE invoice SET...... #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I ran this code:

if ($d->on("success")){

          foreach ($_POST as $k=>$v){
            if (($k!="id") and ($k!="op")){
              $this->db->set($k,$v);
            }
          }
          $this->db->set("closed",1)->where("id",$_POST["id"])->update("invoice");
          $data['content']="Invoice submitted.";
        }

What is the expected output? What do you see instead?
I want see my 'operation succeed' message, but I see thiserror message:

6, database table is locked, UPDATE invoice SET no = '3', date_issue = 
'2011-11-03', date_pay = '2011-11-03', contractor_id = '1', contractor_text = 
'xxx', subscriber_id = '1', subscriber_text = 'xxx', mention = 'xx', issued_by 
= 'xx', note = 'xxxx', closed = 1 WHERE id = '3'

What version of the product are you using? On what operating system?
rapyd-cms beta2 

Please provide any additional information below.

Previous code is:

$this->db->select("*")->from("invoice")->where("id",$no)->where("closed",1)->get
();
      $r=$this->db->row_array();
      if ($r['id']){
        $data['content']="This invoice is closed!";
      }else{

        $this->db->select("*")->from("invoice")->where("id",$no)->get();
        $da=$this->db->row_array();

plus some field definitions....      

Original issue reported on code.google.com by stra...@seznam.cz on 3 Nov 2011 at 9:01

GoogleCodeExporter commented 9 years ago
hint:

my home server:
everything OK, php 5.3.6, sqlite 3.7.4

production server:
this ugly bug, php 5.3.8, sqlite 3.3.6

Original comment by stra...@seznam.cz on 3 Nov 2011 at 9:30

GoogleCodeExporter commented 9 years ago
seems a write permission issue..

1. all "db" folders (application/db, and modules/{module}/db) need to be  777 
(recursive).

2. after a bit of google search.. i've found:
http://www.sqlitemanager.org/en/tips/php-sqlite3/database-table-is-locked.html
I never used "closeCursor()" method,  but we can try to add this after each 
"fetchAll"  or "fetch" ... or just in the "execute" method of this driver:
http://code.google.com/p/rapyd-framework/source/browse/trunk/core/libraries/driv
ers/database_pdo.php

can you try to play with this?

Original comment by felice.ostuni on 4 Nov 2011 at 8:40

GoogleCodeExporter commented 9 years ago
I tried second option. I added one row in execute function in database_pdo.php 
file and now it seems to be OK. Thanks a lot for help.

My modified function now looks that:

protected function execute($sql)
    {
        //rrr : reset result resources
        if (is_object ($this->result_id)){ $this->result_id->closeCursor(); }
        $this->pdo_results  = '';
        $this->pdo_index = 0;
        $this->result_id     = FALSE;
        $this->result_array = array();
        $this->result_object = array();

        return $this->conn_id->query($sql);

    }

If I detect some bad side effect, I will post it here.

Original comment by stra...@seznam.cz on 4 Nov 2011 at 10:44

GoogleCodeExporter commented 9 years ago
perfect, I'll try this patch on some other env.  then I'll commit.
thnks for reporting.

Original comment by felice.ostuni on 7 Nov 2011 at 11:24