Overview
Comment:Correction pour les sous-appels de la fonction + suppression bidouille instructions sqlite3
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | stable | 0.5.9
Files: files | file ages | folders
SHA1: fc0e5120524afbcb5fe32ecc6b098aeaefc5d89d
User & Date: bohwaz on 2013-09-29 11:50:58
Other Links: manifest | tags
Context
2013-10-01
02:26
Merge [464b2f5d24] correction Ă©valuation entrĂ©e check-in: dfb7954c91 user: bohwaz tags: stable, 0.5.9
2013-09-29
11:50
Correction pour les sous-appels de la fonction + suppression bidouille instructions sqlite3 check-in: fc0e512052 user: bohwaz tags: stable, 0.5.9
11:50
Correction pour les sous-appels de la fonction check-in: c0b53fcbb7 user: bohwaz tags: trunk
11:43
suppression bidouille avec les dates pour sqlite3 check-in: 187b73615f user: bohwaz tags: trunk
11:27
Merges multiples de corrections dans la branche stable check-in: 3d710711d8 user: bohwaz tags: stable, 0.5.9
Changes

Modified include/class.db.php from [5164eaa4a3] to [4856b84bc1].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177





178
179
180
181
182
183
184
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
    {
        $subject = substr_replace($subject, $replace, $pos, strlen($search));
    }

    return $subject;
}

define('SQLITE3_INSTRUCTION', 42);

class SQLite3_Instruction
{
    protected $instruction = '';

    public function __construct($instruction)
    {
        $this->instruction = $instruction;
    }

    public function __toString()
    {
        return $this->instruction;
    }
}

class DB extends \SQLite3
{
    static protected $_instance = null;

    protected $_running_sum = 0.0;

    static public function getInstance($create = false)
................................................................................
            return SQLITE3_INTEGER;
        elseif (is_bool($arg))
            return SQLITE3_INTEGER;
        elseif (is_null($arg))
            return SQLITE3_NULL;
        elseif (is_string($arg))
            return SQLITE3_TEXT;
        elseif (is_object($arg) && $arg instanceof SQLite3_instruction)
            return SQLITE3_INSTRUCTION;
        else
            throw new \InvalidArgumentException('Argument '.$name.' is of invalid type '.gettype($arg));
    }

    public function simpleStatement($query, $args = array())
    {
        $statement = $this->prepare($query);
        $nb = $statement->paramCount();

        if (!empty($args))
        {





            if (count($args) != $nb)
            {
                throw new \LengthException('Only '.count($args).' arguments, but '.$nb.' are required by query.');
            }

            reset($args);

................................................................................
                return floatval($value);
            case SQLITE3_INTEGER:
                return intval($value);
            case SQLITE3_NULL:
                return 'NULL';
            case SQLITE3_TEXT:
                return '\'' . $this->escapeString($value) . '\'';
            case SQLITE3_INSTRUCTION:
                return (string) $value;
        }
    }

    /**
     * Simple INSERT query
     */
    public function simpleInsert($table, $fields)







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<











>
>
>
>
>







 







<
<







10
11
12
13
14
15
16

















17
18
19
20
21
22
23
...
141
142
143
144
145
146
147


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
236
237
238
239
240
241
242


243
244
245
246
247
248
249
    {
        $subject = substr_replace($subject, $replace, $pos, strlen($search));
    }

    return $subject;
}


















class DB extends \SQLite3
{
    static protected $_instance = null;

    protected $_running_sum = 0.0;

    static public function getInstance($create = false)
................................................................................
            return SQLITE3_INTEGER;
        elseif (is_bool($arg))
            return SQLITE3_INTEGER;
        elseif (is_null($arg))
            return SQLITE3_NULL;
        elseif (is_string($arg))
            return SQLITE3_TEXT;


        else
            throw new \InvalidArgumentException('Argument '.$name.' is of invalid type '.gettype($arg));
    }

    public function simpleStatement($query, $args = array())
    {
        $statement = $this->prepare($query);
        $nb = $statement->paramCount();

        if (!empty($args))
        {
            if (count($args) == 1 && is_array($args[0]))
            {
                $args = $args[0];
            }
            
            if (count($args) != $nb)
            {
                throw new \LengthException('Only '.count($args).' arguments, but '.$nb.' are required by query.');
            }

            reset($args);

................................................................................
                return floatval($value);
            case SQLITE3_INTEGER:
                return intval($value);
            case SQLITE3_NULL:
                return 'NULL';
            case SQLITE3_TEXT:
                return '\'' . $this->escapeString($value) . '\'';


        }
    }

    /**
     * Simple INSERT query
     */
    public function simpleInsert($table, $fields)

Modified include/class.wiki.php from [45ce812523] to [e48b424b27].

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
        }

        if (isset($data['parent']) && (int)$data['parent'] == (int)$id)
        {
            $data['parent'] = 0;
        }

        $data['date_modification'] = new SQLite3_Instruction('CURRENT_TIMESTAMP');

        if (isset($data['date_creation']) && !($data['date_creation'] > 0))
        {
            unset($data['date_creation']);
        }
        else
        {
            $data['date_creation'] = new SQLite3_Instruction('datetime('.(int)$data['date_creation'].', \'unixepoch\')');
        }

        $db->simpleUpdate('wiki_pages', $data, 'id = '.(int)$id);
        return true;
    }

    public function delete($id)
................................................................................

        $data['id_page'] = $id;
        $data['revision'] = $revision;

        $db->simpleInsert('wiki_revisions', $data);
        $db->simpleUpdate('wiki_pages', array(
            'revision'          =>  $revision,
            'date_modification' =>  new SQLite3_Instruction('CURRENT_TIMESTAMP'),
        ), 'id = '.(int)$id);

        return true;
    }

    public function search($query)
    {







|







|







 







|







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
        }

        if (isset($data['parent']) && (int)$data['parent'] == (int)$id)
        {
            $data['parent'] = 0;
        }

        $data['date_modification'] = date('Y-m-d H:i:s');

        if (isset($data['date_creation']) && !($data['date_creation'] > 0))
        {
            unset($data['date_creation']);
        }
        else
        {
            $data['date_creation'] = time();
        }

        $db->simpleUpdate('wiki_pages', $data, 'id = '.(int)$id);
        return true;
    }

    public function delete($id)
................................................................................

        $data['id_page'] = $id;
        $data['revision'] = $revision;

        $db->simpleInsert('wiki_revisions', $data);
        $db->simpleUpdate('wiki_pages', array(
            'revision'          =>  $revision,
            'date_modification' =>  date('Y-m-d H:i:s'),
        ), 'id = '.(int)$id);

        return true;
    }

    public function search($query)
    {