Log message #4223979

# At Username Text
# Jan 27th 2020, 15:09 neon1024 `->dropForeignKey('script_id')`
# Jan 27th 2020, 15:09 neon1024 The trick is to drop the foreign key constraint and the index
# Jan 27th 2020, 15:03 neon1024 The error doesn’t tell me which foreign key constraint it is. I’m presuming it can’t be the one I’m removing, and the constraint isn’t inversed in the referenced table
# Jan 27th 2020, 15:02 neon1024 PDOException: SQLSTATE[HY000]: General error: 1553 Cannot drop index ‘slot_contents_script_fk’: needed in a foreign key constraint in /Users/davidyell/Sites/TelecomsCCA/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:184
# Jan 27th 2020, 15:01 neon1024 When trying to remove an index from a column, how can I find out which constraint to look for when seeing this
# Jan 27th 2020, 14:27 scuadra thank you for the help, I fixed the notices.
# Jan 27th 2020, 14:26 neon1024 My brain is scrambled by this duplication issue :)
# Jan 27th 2020, 14:22 neon1024 Perhaps I was confused with associated properties
# Jan 27th 2020, 14:22 neon1024 But yes
# Jan 27th 2020, 14:22 neon1024 I meant, when you’re looping
# Jan 27th 2020, 14:22 admad > and you’d get an array of entities no, you get a `ResultSet` instance which is traversable :)
# Jan 27th 2020, 14:20 neon1024 ..and you’d get an array of entities
# Jan 27th 2020, 14:20 neon1024 You don’t need to use `toArray()` if you’re looping
# Jan 27th 2020, 14:20 neon1024 Probably `$row`
# Jan 27th 2020, 14:19 scuadra @neon1024 $directors variable, right
# Jan 27th 2020, 14:19 admad stop trying to access non existent array keys
# Jan 27th 2020, 14:19 neon1024 Just means your variable is null
# Jan 27th 2020, 14:18 slackebot $directors = []; foreach ($query as $row) { $directors[$row['director']['id']] = $row['director']['name']; //THIS IS THE LINE IN THE NOTICE } return $directors;```
# Jan 27th 2020, 14:18 scuadra Hello. I recently upgraded my PHP version to 7.4. SInce then I am getting some notices in my app (Cake 3.7). I get "_Trying to access array offset on value of type null"_ error and here is the code: ```$query = $this->find('all') ->select([ 'Director.id', 'Director.name' ]) ->distinct($this->_alias . '.director_id') ->where([ $this->_alias . '.id IS NOT' => null ]) ->orderAsc('Director.name') ->contain(['Director']) ->toArray();
# Jan 27th 2020, 14:11 neon1024 Thanks
# Jan 27th 2020, 14:11 admad table alias
# Jan 27th 2020, 14:08 neon1024 Anyone know if the `associated` option in `save()` is the Table class name or the property alias?
# Jan 27th 2020, 13:42 mark.mikkelson depends what you want to do, how much you're using it in view(s) etc. Personally, I'd just access session stuff that's being used in views through the view helper. Unless I was saving it into database or running some sort of script/function. But that's just me or i already had the same info in the loaded in my controller(s)
# Jan 27th 2020, 13:41 mark.mikkelson or i already had the same info in the loaded in my controller(s)
# Jan 27th 2020, 13:41 mark.mikkelson depends what you want to do, how much you're using it in view(s) etc. Personally, I'd just access session stuff that's being used in views through the view helper. Unless I was saving it into database or running some sort of script/function. But that's just me
# Jan 27th 2020, 13:30 alexdd55976 @mark.mikkelson opinion: you think it makes sense to set this session request in the app controller to make it available in any view? it seems straight forward to me
# Jan 27th 2020, 13:26 mark.mikkelson to do it in a view, there's a helper: ```// Prior to 3.6.0 use session() instead. $name = $this->getRequest()->getSession()->read('User.name'); // If you are accessing the session multiple times, // you will probably want a local variable. $session = $this->getRequest()->getSession(); $name = $session->read('User.name');``` from : https://book.cakephp.org/3/en/views/helpers/session.html#Cake\View\Helper\SessionHelper
# Jan 27th 2020, 13:24 alexdd55976 set it in controller? is there a helper? should i code a helper?
# Jan 27th 2020, 13:24 alexdd55976 guys, what is the best way to access session data in a view?
# Jan 27th 2020, 13:05 mark.mikkelson anybody able to tell me what this means? "Headers are not sent when set. Instead, they are held until the response is emitted by `Cake\Http\Server`." From the cake docs on setting headers? I've set a header but they aren't showing in the response. Do i need to return an instance of http/server?
# Jan 27th 2020, 12:50 neon1024 Ah, false, `pr()` doesn’t display it, good job `var_dump()` does
# Jan 27th 2020, 12:49 neon1024 For some reason the `save()` call for the entity, returns void, which doesn’t seem right
# Jan 27th 2020, 12:36 slackebot $connection_table->insert($entry_data); $connection_table->saveData(); endforeach; // Remove the column "project_state_id" from the table "projects" $project_table = $this->table('projects'); $project_table->removeColumn('project_state_id'); $project_table->save();```
# Jan 27th 2020, 12:36 slackebot $connection_table->create(); // Transfer already present data from table "projects" into the connection table $tableLocator = TableRegistry::getTableLocator(); $ProjectsTable = $tableLocator->get('Projects'); $all_projects = $ProjectsTable->find('all')->toArray(); foreach($all_projects as $project): $entry_data = ['project_id' => $project->id, 'project_state_id' => $project-> project_state_id];
# Jan 27th 2020, 12:36 kevin.pfeifer I found out how i can do this. See here: ``` // Create new connection table to connect table "projects" with "project_states" $connection_table = $this->table('projects_project_states', ['id' => false, 'primary_key' => ['project_id', 'project_state_id']]); $connection_table->addColumn('project_id', 'integer', ['signed' => false]); $connection_table->addColumn('project_state_id', 'integer', ['signed' => false]);
# Jan 27th 2020, 12:35 neon1024 Mass assignment isn’t an issue, $_accessible, as I’m not using patchEntity or newEntity
# Jan 27th 2020, 12:35 neon1024 Or if I need to modify the entity instance and set it back to the parent associated property
# Jan 27th 2020, 12:35 neon1024 As the Duplicatable behaviour doesn’t work for this use-case
# Jan 27th 2020, 12:34 neon1024 That this will allow duplication of an entity
# Jan 27th 2020, 12:34 neon1024 ```$scriptComposedOf->get('slot')->get('contents')->isNew(true); $scriptComposedOf->get('slot')->get('contents')->set('id', null);```
# Jan 27th 2020, 12:34 neon1024 Based on the assumption