Search the Community
Showing results for tags 'initialization'.
-
Does anyone have a recommendation for creating a MySQL connection pool on an Apache httpd server? Every invocation of PW is slowed on this system with about 1 second taken up before any useful work is done, primarily in establishing a database server connection. This is on a VPS, so admittedly it isn't fully under our control, but still...
-
- database
- performance
-
(and 2 more)
Tagged with:
-
I've created an Inputfield module but have some questions about how the initialization works. The field works, but I don't understand how the class is being initialized and default values supplied to ___render. If I don't set the value in my code that executes wire('modules')->get('InputfieldMine') then no default value is supplied to ___render even though it's clearly set in __construct. Excerpted logic for my module/class (InputfieldMine): public function __construct() { parent::__construct(); $this->set('minLength', 6); wire('log')->save('trace', "__construct $this->minLength"); } public function init() { parent::init(); // other stuff $ml = $this->minLength; wire('log')->save('trace', "init $ml"); } public function ___render() { $ml = $this->minLength; wire('log')->save('trace', "___render $ml"); } I'm writing a log in __construct, init, and ___render. Excerpted logic from where I'm using the InputfieldMine: // get a my field wire('log')->save('trace', 'B4 LOAD'); $field = wire('modules')->get("InputfieldMine"); wire('log')->save('trace', "AFTER LOAD $field->minLength"); // ellided setting of attributes and properties $field->minLength = 6; wire('log')->save('trace', "AFTER SET $field->minLength"); $form->add($field); I'm writing a log before loading the module, right after loading the module, and after setting the minLength. The log sequence I get is: B4 LOAD __construct init AFTER LOAD AFTER SET 6 ___render 6 So it's clear that the ->get method causes both the constructor and the init function to get invoked as I'd expect. What's not clear to me is why the value set in __construct isn't get-able after $this->set('minLength', 6); is executed. The 6 is present in a var_dump - it's in the data: array['minLength']. If I remove the line: $field->minLength = 6; right before the "AFTER SET" log call then the value is null when ___render is called. What is the purpose of setting minLength to 6 in the constructor? And how would I cause the Inputfield to use it?
- 8 replies
-
- module
- initialization
-
(and 1 more)
Tagged with: