Thinkphp Tutorial Implement Tips

Official website:

1. Download full version and wampserver. Extract full version under /wamp/www
2. Follow the instruction, .htaccess is no suffix.
3. Create database, using phpMyAdmin in wampserver, the password for mysql is empty.
the path for database is ” D:\wamp\bin\mysql\mysql5.5.24\data ”
4. Auto fill/verify failed.
In my case, I wrong spell class to calss ….
5. When define read() function, still defined in FormAction.class.php
6. Add ” ‘_multi’=>true “, to represent it is multi condition match

7. Connect sqlite database, first move D:\wamp\www\ThinkPHP\Extend\Driver\Db\DbSqlite.class.php to D:\wamp\www\ThinkPHP\Lib\Driver\Db\DbSqlite.class.php
Or the system will report that it did not support Sqlite.
In config.php write:
‘DB_TYPE’ => ‘pdo’,
‘DB_DSN’ => ‘sqlite:’ . DATA_PATH . ‘/test.db’,
‘DB_PREFIX’ => null, // 数据库表前缀
‘DB_CHARSET’ => ‘utf8’, // 数据库编码默认采用utf8
‘DB_FIELDS_CACHE’ => false, // 启用字段缓存

. DATA_PATH . means you should put db in app/runtime/data/
In indexAction.class.php, try
// $model = new Model();

// 创建一个表 applications
// $model->execute(“CREATE TABLE applications ( id INT ( 10 ) NOT NULL PRIMARY KEY , username VARCHAR ( 250 ) NOT NULL )”);

// 插入一条数
// $model->execute(“INSERT INTO applications ( id , username )VALUES ( 1 , ‘PHP init learn’ )”);

// 生成一个demo对应的Model对象
$DemoModel = M (‘applications’);

// 取所有数据
$result = $DemoModel->select();

// 打印数据。

Then you will see the db data, all done now.

8. When use display(), we must use $this->display(), or else it will said no function definition. Because it is defined in Action class, and we modified $this->application = $DemoModel->select(); then in index.html, we should use


9. Using sql to get multitable results:
$DemoModel = M (‘applications’);

$sql = “select as name,a.power as power, as device,a.apptype as apptype from applications as a,devices as d where and’$AppName’ and a.apptype=’$AppCateID’“;

$app = $DemoModel->query($sql);

10. add excel export: put template.xls in /testproject/file and
add in class:
include ‘PHPExcel.php’;
include ‘PHPExcel/IOFactory.php’;
Put phpExcel folder and phpExcel.php in \wamp\www\ThinkPHP\Extend\Vendor

11. send info from one function to another, using hidden in html:
<!–App Name:

<INPUT type="hidden” name =”appCateIDOld” value={$dname}>

12. Table in html:




This entry was posted in Website design and implement. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

App Name Power Device Type
{$} {$} {$data.power} {$data.device}
ali on Oprofile 0.9.6 ——-…
Ola on Oprofile 0.9.6 ——-…
tran dung on Oprofile 0.9.6 ——-…
Jisu on Oprofile 0.9.6 ——-…
Sachin Agarwalla on Oprofile 0.9.6 ——-…
  • Archives

  • Categories

  • Meta