X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=doc%2Fcsql.xml;h=284de249342ffdf05aff263f9b1fc574f8bddc2d;hb=f7a356bb4c11d062eeeb5d4aaf4e187a3cb15a27;hp=09ac4db272c5b5519f8a18e407698c75939db673;hpb=afe872863374de73b2f2ef767e742a40d7465e4a;p=clsql.git diff --git a/doc/csql.xml b/doc/csql.xml index 09ac4db..284de24 100644 --- a/doc/csql.xml +++ b/doc/csql.xml @@ -177,10 +177,12 @@ mapped into a database). They would be defined as follows: :nulls-ok t :initarg :email) (companyid - :type integer) + :type integer + :initarg :companyid) (managerid :type integer - :nulls-ok t)) + :nulls-ok t + :initarg :managerid)) (:base-table employee)) (clsql:def-view-class company () @@ -193,7 +195,8 @@ mapped into a database). They would be defined as follows: :type (string 100) :initarg :name) (presidentid - :type integer)) + :type integer + :initarg :presidentid)) (:base-table company)) @@ -463,7 +466,7 @@ first need to create our tables in the database: -Note: the file doc/clsql-tutorial.lisp contains +Note: the file examples/clsql-tutorial.lisp contains view class definitions which you can load into your list at this point in order to play along at home. @@ -479,22 +482,25 @@ any other CLOS object: -(defvar employee1 (make-instance 'employee - :emplid 1 - :first-name "Vladamir" - :last-name "Lenin" - :email "lenin@soviet.org")) - (defvar company1 (make-instance 'company :companyid 1 + :presidentid 1 :name "Widgets Inc.")) +(defvar employee1 (make-instance 'employee + :emplid 1 + :first-name "Vladamir" + :last-name "Lenin" + :email "lenin@soviet.org" + :companyid 1)) (defvar employee2 (make-instance 'employee :emplid 2 :first-name "Josef" :last-name "Stalin" - :email "stalin@soviet.org")) + :email "stalin@soviet.org" + :companyid 1 + :managerid 1)) @@ -508,26 +514,6 @@ In order to insert an objects into the database we use the (clsql:update-records-from-instance company1) - -Now we can set up some of the relations between employees and -companies, and their managers. The -ADD-TO-RELATION method provides us with an easy -way of doing that. It will update both the relation slot, as well as -the home-key and foreign-key slots in both objects in the relation. - - - -;; Lenin manages Stalin (for now) -(clsql:add-to-relation employee2 'manager employee1) - -;; Lenin and Stalin both work for Widgets Inc. -(clsql:add-to-relation company1 'employees employee1) -(clsql:add-to-relation company1 'employees employee2) - -;; Lenin is president of Widgets Inc. -(clsql:add-to-relation company1 'president employee1) - - After you make any changes to an object, you have to specifically tell &clsql; to update the &sql; database. The