Skip to content

Commit a3b824f

Browse files
committed
database - compatibility with any database
* provide a default sqlite using pdo module and db file, * set default connection to sqlite, but leave mysql example older * return indexauth check to use the database, but not imap yet * improve README for database documentation
1 parent 7e58ec2 commit a3b824f

File tree

5 files changed

+48
-53
lines changed

5 files changed

+48
-53
lines changed

webappdb/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11

2-
The DB
2+
The Database is just a simple table, with simple columns,
3+
the model just check both arguments and returns all the data,
4+
5+
## Compatibility
6+
7+
The DB is designed using mysqlworkbench but the generated sql file
8+
must have some tuneup to be compatible with all the others DB:
9+
10+
* remove any `COMMENTS ""`
11+
* remove any `ENGINE=`
12+
* remove any special comun data like `AUTOINCREMENT`
13+
14+
## Desing
15+
16+
The mysqlworkbench is pretty complete you can use it and generate
17+
the database SQL file later, so tuning with previous hints,
18+
will make it compatible, just use `; -- COMMENT`.
19+
20+
Then inside mysqlworkbench use comments to describe the dictionary.
321

422
![](codeigniter.png)

webappdb/codeigniter.sql

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
1-
-- phpMyAdmin SQL Dump
2-
-- version 4.7.4
3-
-- https://www.phpmyadmin.net/
4-
--
5-
-- Host: 127.0.0.1
61
-- Generation Time: Feb 05, 2018 at 07:10 AM
7-
-- Server version: 10.1.28-MariaDB
8-
-- PHP Version: 7.1.10
9-
10-
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11-
SET AUTOCOMMIT = 0;
12-
START TRANSACTION;
13-
SET time_zone = "+00:00";
14-
15-
16-
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17-
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18-
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19-
/*!40101 SET NAMES utf8mb4 */;
20-
21-
--
22-
-- Database: `codeigniter`
23-
--
242

253
-- --------------------------------------------------------
264

@@ -32,37 +10,12 @@ CREATE TABLE `users` (
3210
`id` int(11) NOT NULL,
3311
`username` varchar(40) NOT NULL,
3412
`userpass` varchar(40) NOT NULL
35-
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
13+
);
3614

3715
--
3816
-- Dumping data for table `users`
3917
--
4018

4119
INSERT INTO `users` (`id`, `username`, `userpass`) VALUES
42-
(1, 'ndevierte@gmail.com', 'nurhodelta'),
43-
(2, 'gemalyn@gmail.com', 'cepe');
44-
45-
--
46-
-- Indexes for dumped tables
47-
--
48-
49-
--
50-
-- Indexes for table `users`
51-
--
52-
ALTER TABLE `users`
53-
ADD PRIMARY KEY (`id`);
54-
55-
--
56-
-- AUTO_INCREMENT for dumped tables
57-
--
58-
59-
--
60-
-- AUTO_INCREMENT for table `users`
61-
--
62-
ALTER TABLE `users`
63-
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
64-
COMMIT;
20+
(1, 'demo', 'demo');
6521

66-
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
67-
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
68-
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

webappweb/codeigniter.db

8 KB
Binary file not shown.

webappweb/config/database.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@
7373
$active_group = 'default';
7474
$query_builder = TRUE;
7575

76-
$db['default'] = array(
76+
$db['mysql'] = array(
7777
'dsn'=> '',
7878
'hostname' => 'localhost',
7979
'username' => 'root',
8080
'password' => 'root',
81-
'database' => 'mysql',
81+
'database' => 'codeigniter',
8282
'dbdriver' => 'mysqli',
8383
'dbprefix' => '',
8484
'pconnect' => FALSE,
@@ -94,3 +94,27 @@
9494
'failover' => array(),
9595
'save_queries' => (ENVIRONMENT !== 'production')
9696
);
97+
98+
$db['sqlite'] = array(
99+
'dsn'=> 'sqlite:'.APPPATH.'/codeigniter.db',
100+
'hostname' => '',
101+
'username' => '',
102+
'password' => '',
103+
'database' => '',
104+
'dbdriver' => 'pdo', // pdo only for CI3, for CI2 use mysql/postgres/odbc
105+
'dbprefix' => '',
106+
'pconnect' => FALSE,
107+
'db_debug' => (ENVIRONMENT !== 'production'),
108+
'cache_on' => FALSE,
109+
'cachedir' => '',
110+
'char_set' => 'utf8',
111+
'dbcollat' => 'utf8_general_ci',
112+
'swap_pre' => '',
113+
'encrypt' => FALSE,
114+
'compress' => FALSE,
115+
'stricton' => FALSE,
116+
'failover' => array(),
117+
'save_queries' => (ENVIRONMENT !== 'production')
118+
);
119+
120+
$db['default'] = $db['sqlite'];

webappweb/controllers/Indexauth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function auth($action = 'logout', $username = NULL, $userclave = NULL)
2727

2828
$im_access = TRUE;//$this->usersmodel->loginimap($username, $userclave);
2929

30-
$rs_access = array('user'=>'pepe');//$this->usersmodel->logindb($username, $userclave);
30+
$rs_access = $this->usersmodel->logindb($username, $userclave);
3131
}
3232

3333
$data = array();

0 commit comments

Comments
 (0)