gpt4 book ai didi

mysql - 无法从subsonic 2.2插入到mysql(Joomla CMS数据库)

转载 作者:行者123 更新时间:2023-11-29 15:08:57 24 4
gpt4 key购买 nike

我无法将记录插入 mysql 数据库(joomla CMS 表 jos_content)。收到:异常:“您的 SQL 语法有错误;请检查与您的 MySQL 服务器版本相对应的手册,以了解要使用的正确语法

任何想法,可能有什么问题,因为我只是从源记录复制除自动增量之外的所有数据(相同的数据库,相同的表!)

//using Subsonic 2.2 , connecting to mysql server 5.1.33-community

//just to test that reading works OK
JosContentCollection jcc = new JosContentCollection().Load();
foreach (var content in jcc)
{
Console.WriteLine(content.Id + " " + content.Title);
}
//foreach works OK... shows all records



JosContent jcSource = new JosContent(2); //use previous record as source
Console.WriteLine("Read record:"+jcSource.Id + " " + cSource.Title);
//read OK... record was found and shown!


JosContent jc= new JosContent();
//all records copied from source record except autoincremental field
//jc.Id = //auto increment field
jc.Title = "test from c# "; // +DateTime.Now.ToShortTimeString();
jc.AliasX = "test-from-c";
jc.TitleAlias = jcSource.TitleAlias; //String.Empty;
jc.Introtext = jcSource.Introtext; // "short intro text";
jc.Fulltext = jcSource.Introtext; // "long html";
jc.State = jcSource.State; // true;
jc.Sectionid = jcSource.Sectionid; // 1;
jc.Mask = jcSource.Mask; //0;
jc.Catid = jcSource.Catid;
jc.Created = jcSource.Created; // DateTime.Now;
jc.CreatedBy = jcSource.CreatedBy;
jc.CreatedByAlias = jcSource.CreatedByAlias;
jc.Modified = jcSource.Modified; // DateTime.Now;
jc.ModifiedBy = jcSource.ModifiedBy;
jc.CheckedOut = jc.CheckedOut;
jc.CheckedOutTime = jcSource.CheckedOutTime; // DateTime.Now;
jc.PublishUp = jcSource.PublishUp; // DateTime.Now;
jc.PublishDown = jcSource.PublishDown; // DateTime.Now;
jc.Images = jcSource.Images;
jc.Urls = jcSource.Url;
jc.Attribs = jcSource.Attribs;
jc.Version = jc.Version;
jc.Parentid = jc.Parentid;
jc.Ordering = jc.Ordering;
jc.Metakey = jcSource.Metakey;
jc.Metadesc = jcSource.Metadesc;
jc.Access = jcSource.Access;
jc.Hits = jcSource.Hits;
jc.Metadata = jcSource.Metadata;


jc.Save(); //Generates exception:
/*
MySql.Data.MySqlClient.MySqlException was unhandled
Message="You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext,state,sectionid,mask,catid,created,created_by,created_by_alias,modified' at line 1"
Source="MySql.Data"
ErrorCode=-2147467259
Number=1064
StackTrace:
at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar()
at SubSonic.MySqlDataProvider.ExecuteScalar(QueryCommand qry)
at SubSonic.DataService.ExecuteScalar(QueryCommand cmd)
at SubSonic.ActiveRecord`1.Save(String userName)
at SubSonic.ActiveRecord`1.Save()
at joomlamysqlapi.Program.VsaVsebina() in R:\joomlamysqlapi\Program.cs:line 114
at joomlamysqlapi.Program.Main(String[] args) in R:\joomlamysqlapi\Program.cs:line 13
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

-- ----------------------------
-- Table structure for `jos_content`
-- ----------------------------
DROP TABLE IF EXISTS `jos_content`;
CREATE TABLE `jos_content` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
`alias` varchar(255) NOT NULL DEFAULT '',
`title_alias` varchar(255) NOT NULL DEFAULT '',
`introtext` mediumtext NOT NULL,
`fulltext` mediumtext NOT NULL,
`state` tinyint(3) NOT NULL DEFAULT '0',
`sectionid` int(11) unsigned NOT NULL DEFAULT '0',
`mask` int(11) unsigned NOT NULL DEFAULT '0',
`catid` int(11) unsigned NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(11) unsigned NOT NULL DEFAULT '0',
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(11) unsigned NOT NULL DEFAULT '0',
`checked_out` int(11) unsigned NOT NULL DEFAULT '0',
`checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`images` text NOT NULL,
`urls` text NOT NULL,
`attribs` text NOT NULL,
`version` int(11) unsigned NOT NULL DEFAULT '1',
`parentid` int(11) unsigned NOT NULL DEFAULT '0',
`ordering` int(11) NOT NULL DEFAULT '0',
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`access` int(11) unsigned NOT NULL DEFAULT '0',
`hits` int(11) unsigned NOT NULL DEFAULT '0',
`metadata` text NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_section` (`sectionid`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_state` (`state`),
KEY `idx_catid` (`catid`),
KEY `idx_createdby` (`created_by`)
) ENGINE=MyISAM AUTO_INCREMENT=58 DEFAULT CHARSET=utf8;
*/

最佳答案

我猜测两件事:

1) 中文本可能无法正确识别并在 MySQL.tt 中输入。您可能想在 Save() 上设置一个断点并查看生成的 SQL。

2)我们遇到问题的未签名内容。最新的源应该可以解决这个问题(注意:这并不意味着 3.0.0.3 - 它意味着当前的源)。

如果您可以使用调试器推送 SQL,那将会有所帮助。

关于mysql - 无法从subsonic 2.2插入到mysql(Joomla CMS数据库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1383556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com