coderenaline Posted March 31, 2015 Share Posted March 31, 2015 I dont be an pro coder, but understand all what i want to know so far. Now i try to understand the code from processwire. Espacially how PW does get and set data in the database. I look Database....php, WireData.php and so on and many set() and get()-methods therein. And i know of the existence from $db. But i dont understand or see which method(s) in which class(es) used for SQL-Statements - especially in the case of fields. So i look the code from the example "event" from ryan. I see set() and get()-methods in event.php. Can anyone help me and hands on me further? Which methods and classes set and get data from the database? How can i manipulate the sort-order? Thank in advance. I know how i can wrote and read in the DB with the $db, but i would like understand the processwire-way. Link to comment Share on other sites More sharing options...
horst Posted April 1, 2015 Share Posted April 1, 2015 (edited) The processwire way is in 95% to use the API, and not to write directly to the DB. (Using direct access is for rare edge cases or maybe sometimes when create a module) PS: Ah, it is your first post here. Welcome! Edited April 1, 2015 by horst 1 Link to comment Share on other sites More sharing options...
coderenaline Posted April 2, 2015 Author Share Posted April 2, 2015 I dont understand the "event" example from ryan. Where are the methodes for set and get the variables from the db? How can i write own modules without understanding this basics? Thx Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 2, 2015 Share Posted April 2, 2015 This is abstracted in the functions sleepValue() and wakeupValue(). You don't need to write own sql statements. 1 Link to comment Share on other sites More sharing options...
horst Posted April 2, 2015 Share Posted April 2, 2015 I don't know the "event-example". What is it? Where is it? (hyperlink?) Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 2, 2015 Share Posted April 2, 2015 I think he's talking about FieldtypeEvent the kinda example for building own fieldtypes. 2 Link to comment Share on other sites More sharing options...
horst Posted April 2, 2015 Share Posted April 2, 2015 Ah, thanks. https://processwire.com/talk/topic/5040-events-fieldtype-inputfield-how-to-make-a-table-fieldtypeinputfield/ Link to comment Share on other sites More sharing options...
coderenaline Posted April 2, 2015 Author Share Posted April 2, 2015 Hello. Yes, this: https://processwire.com/talk/topic/5040-events-fieldtype-inputfield-how-to-make-a-table-fieldtypeinputfield/ This example sorts after date with the db column "sort". I couldnt see where the content of the db-column "sort" is defined. Now im searching for sleepValue() and wakeupValue() in the code. By the way, i'm german too. Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 2, 2015 Share Posted April 2, 2015 The sort column isn't explicitly set by the module. It's added by FieldtypeMulti::getDatabaseSchema(), which is a parent class of the event fieldtype. 1 Link to comment Share on other sites More sharing options...
coderenaline Posted April 2, 2015 Author Share Posted April 2, 2015 Ok, in the hookable method "___sleepValue()" in FieldtypeEvents.module.php in line 110 ive found: $value->sort('date'); One questions is answered. Not 100% understand all the code but one big step further. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now