Query/tests/databases/sqlite/sqlite-qb.php

87 lines
1.8 KiB
PHP
Raw Normal View History

2012-03-15 09:25:18 -04:00
<?php
/**
2012-04-10 14:06:34 -04:00
* OpenSQLManager
2012-03-15 09:25:18 -04:00
*
2012-04-10 14:06:34 -04:00
* Free Database manager for Open Source Databases
2012-03-15 09:25:18 -04:00
*
* @author Timothy J. Warren
2013-01-02 14:26:42 -05:00
* @copyright Copyright (c) 2012 - 2013
2012-04-10 14:06:34 -04:00
* @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license
2012-03-15 09:25:18 -04:00
*/
// --------------------------------------------------------------------------
/**
* Class for testing Query Builder with SQLite
2012-03-15 09:25:18 -04:00
*/
class SQLiteQBTest extends QBTest {
2012-04-24 14:00:44 -04:00
public function __construct()
2012-03-15 09:25:18 -04:00
{
parent::__construct();
2012-04-30 16:06:06 -04:00
$path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db';
2012-03-15 09:25:18 -04:00
$params = new Stdclass();
$params->type = 'sqlite';
$params->file = $path;
$params->host = 'localhost';
2012-11-07 08:42:34 -05:00
$params->prefix = 'create_';
$this->db = Query($params);
2012-03-19 13:58:14 -04:00
// echo '<hr /> SQLite Queries <hr />';
2012-03-15 09:25:18 -04:00
}
// --------------------------------------------------------------------------
public function TestInsertBatch()
{
if (empty($this->db)) return;
$insert_array = array(
array(
'id' => 6,
'key' => 2,
'val' => 3
),
array(
'id' => 5,
'key' => 6,
'val' => 7
),
array(
'id' => 8,
'key' => 1,
'val' => 2
)
);
$query = $this->db->insert_batch('test', $insert_array);
$this->assertNull($query);
}
2014-02-04 20:59:30 -05:00
// --------------------------------------------------------------------------
public function testQueryExplain()
{
$query = $this->db->select('id, key as k, val')
->explain()
->where('id >', 1)
->where('id <', 900)
->get('create_test', 2, 1);
$res = $query->fetchAll(PDO::FETCH_ASSOC);
$expected = array (
array (
'selectid' => '0',
'order' => '0',
'from' => '0',
'detail' => 'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?)',
),
);
$this->assertEqual($expected, $res);
}
2012-03-15 09:25:18 -04:00
}