Function Using themeConfig error message-primary key conflict

Source: Internet
Author: User
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_urlRecords
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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.