Home  >  Article  >  php教程  >  Notes and memos for connecting tp5 to sqlite

Notes and memos for connecting tp5 to sqlite

WBOY
WBOYOriginal
2016-08-08 08:50:042821browse

Until the official announcement of the connection settings of sqlite is made, just make do with it
I hope the official can announce the database connection settings and instructions of sqlite
1. First design the sqlite database file pre.db and put it in application/db
2. Add the database.php file under the module and set it as followsreturn [<br> 'type' => 'sqlite',<br> //'hostname' => ROOT_PATH.'db/pre.db',<br> 'database' => 'pre',<br> 'username' => '',<br> 'password' => '',<br> 'hostport' => '',<br> 'dsn' => 'sqlite:'.ROOT_PATH.'db/pre.db',<br> 'params' => [],<br> 'charset' => 'utf8',<br> 'prefix' => 'yse_',<br> 'debug' => true,<br> 'deploy' => 0,<br> 'rw_separate' => false,<br> 'master_num' => 1,<br> 'slave_no' => '',<br> 'fields_strict' => true,<br> 'resultset_type' => 'array',<br> 'auto_timestamp' => false,<br> 'sql_explain' => false,<br> ];3. Create model model/User.php as followsnamespace appindexmodel;<br> use thinkModel;<br> <br> class User extends Model{<br> <br> }4. The new operations are as follows public function index(){<br> echo 'this is pre/index';<br> <br>          $user = model('User');<br> <br> echo 'row:';<br> $row = $user->get(1);<br>            dump($row);<br> ​​​​dump($row->user_id);<br> ​​​​dump($row['user_id']);<br> } }The attachment is a database

Notes and memos for connecting tp5 to sqlite pre.db.zip ( 464 B downloads: 0 times )

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn