In function. php uses the themeConfig function to create a function that can customize the output content {code ...} error message & quot; DatabaseQueryError & quot; (the database connection is normal and can be output in any article) error code: {code ...} in function. php uses the themeConfig function to implement a function to customize the output content.
function themeConfig($form) { $twitter_url = new Typecho_Widget_Helper_Form_Element_Text('twitter_url', NULL, _t(''), _t('Your Twitter URL'), NULL); $form->addInput($twitter_url); }
The Error message "Database Query Error" is displayed. (The Database connection is normal and all articles can be output)
Error code:
Duplicate entry 'theme:typecho-theme-MaterialDesi-0' for key 'PRIMARY'exception 'Typecho_Db_Query_Exception' with message 'Duplicate entry 'theme:typecho-theme-MaterialDesi-0' for key 'PRIMARY'' in /Applications/MAMP/htdocs/viosey/blog/var/Typecho/Db/Adapter/Mysql.php:77Stack trace:#0 /Applications/MAMP/htdocs/blog/var/Typecho/Db.php(319): Typecho_Db_Adapter_Mysql->query(Object(Typecho_Db_Query), Resource id #29, 2, 'INSERT')#1 /Applications/MAMP/htdocs/blog/var/Widget/Abstract/Options.php(56): Typecho_Db->query(Object(Typecho_Db_Query))#2 /Applications/MAMP/htdocs/blog/var/Widget/Themes/Edit.php(130): Widget_Abstract_Options->insert(Array)#3 /Applications/MAMP/htdocs/blog/var/Widget/Themes/Edit.php(176): Widget_Themes_Edit->config('typecho-theme-M...')#4 /Applications/MAMP/htdocs/blog/var/Widget/Do.php(81): Widget_Themes_Edit->action()#5 /Applications/MAMP/htdocs/blog/var/Typecho/Widget.php(222): Widget_Do->execute()#6 /Applications/MAMP/htdocs/blog/var/Typecho/Router.php(135): Typecho_Widget::widget('Widget_Do', NULL, Array)#7 /Applications/MAMP/htdocs/blog/index.php(23): Typecho_Router::dispatch
Reply content:
Using the themeConfig function in function. php is intended to implement a function to customize the output content.
function themeConfig($form) { $twitter_url = new Typecho_Widget_Helper_Form_Element_Text('twitter_url', NULL, _t(''), _t('Your Twitter URL'), NULL); $form->addInput($twitter_url); }
The Error message "Database Query Error" is displayed. (The Database connection is normal and all articles can be output)
Error code:
Duplicate entry 'theme:typecho-theme-MaterialDesi-0' for key 'PRIMARY'exception 'Typecho_Db_Query_Exception' with message 'Duplicate entry 'theme:typecho-theme-MaterialDesi-0' for key 'PRIMARY'' in /Applications/MAMP/htdocs/viosey/blog/var/Typecho/Db/Adapter/Mysql.php:77Stack trace:#0 /Applications/MAMP/htdocs/blog/var/Typecho/Db.php(319): Typecho_Db_Adapter_Mysql->query(Object(Typecho_Db_Query), Resource id #29, 2, 'INSERT')#1 /Applications/MAMP/htdocs/blog/var/Widget/Abstract/Options.php(56): Typecho_Db->query(Object(Typecho_Db_Query))#2 /Applications/MAMP/htdocs/blog/var/Widget/Themes/Edit.php(130): Widget_Abstract_Options->insert(Array)#3 /Applications/MAMP/htdocs/blog/var/Widget/Themes/Edit.php(176): Widget_Themes_Edit->config('typecho-theme-M...')#4 /Applications/MAMP/htdocs/blog/var/Widget/Do.php(81): Widget_Themes_Edit->action()#5 /Applications/MAMP/htdocs/blog/var/Typecho/Widget.php(222): Widget_Do->execute()#6 /Applications/MAMP/htdocs/blog/var/Typecho/Router.php(135): Typecho_Widget::widget('Widget_Do', NULL, Array)#7 /Applications/MAMP/htdocs/blog/index.php(23): Typecho_Router::dispatch
New Typecho_Widget_Helper_Form_Element_Text () cannot be called in functions, or you need to determine whether the Text component already exists before calling it.
Cause:
1). functions. php is executed every time the page is requested, rather than when the template is installed.
2 ).Typecho_Widget_Helper_Form_Element_Text(...)
A primary key is created in the databasetwitter_url
Records
Therefore, when combined with 1) and 2), the primary key conflict will occur.
For more information, see here: http://www.typechodev.com/index.php/archives/32/