Tuesday, September 22, 2015

Re: CAKE 3.0 Tutorials using SQLITE

If you use the migrations plugin, there is no need to use the correct SQL for creating the database, as cake will take care of generating everything correctly for you.

Check the sections of the tutorial about using the migrations plugin.

On Monday, September 21, 2015 at 3:38:11 AM UTC+2, jacmgr wrote:
I ahev successfully installed cake and Mysql and completed the tutorials for bookmarks and blog.  Now I want to use SQlite.  I can successfully connect to my sqlite database.  I tried using the same Mysql statements found on page 13 of the cookbook that were successful with Mysql; however,  I got several errors and the tables were not created.   Does any one have a export of the sql statements that will work in SQlite.  I really would like to use SQlite.  Any help would be greatly appreciated. These are the errors and not sure how to modify so that they are consistent with cake:

CREATE TABLE users (  id INT AUTO_INCREMENT PRIMARY KEY,  email VARCHAR(255) NOT NULL,  password VARCHAR(255) NOT NULL,  created DATETIME,  modified DATETIME  )

Query executed OK, 0 rows affected. (0.006 s)


CREATE TABLE bookmarks (  id INT AUTO_INCREMENT PRIMARY KEY,  user_id INT NOT NULL,  title VARCHAR(50),  description TEXT,  url TEXT,  created DATETIME,  modified DATETIME,  FOREIGN KEY user_key (user_id) REFERENCES users(id)  )

Error in query (1): near "user_key": syntax error


CREATE TABLE tags (  id INT AUTO_INCREMENT PRIMARY KEY,  title VARCHAR(255),  created DATETIME,  modified DATETIME,  UNIQUE KEY (title)  )

Error in query (1): near "KEY": syntax error



CREATE TABLE bookmarks_tags (  bookmark_id INT NOT NULL,  tag_id INT NOT NULL,  PRIMARY KEY (bookmark_id, tag_id),  FOREIGN KEY tag_key(tag_id) REFERENCES tags(id),  FOREIGN KEY bookmark_key(bookmark_id) REFERENCES bookmarks(id)  )

Error in query (1): near "tag_key": syntax error


* also does not seem to allow 2 primary keys.



--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: