Welcome Guest, Not a member yet? Register   Sign In
Search Results
    Thread: migration: change field type in FK
Post: migration: change field type in FK

I want to change a bunch of fieldtypes (from smallint to mediumint). But most of them are foreign keys, so updating them results in "Cannot change column 'X': used in a foreign key constraint 'Y'... I...
184 Views
2 Replies
02-21-2024, 07:20 AM
sjender
    Thread: SQL query with 1 fixed and 2 OR conditions
Post: SQL query with 1 fixed and 2 OR conditions

Hi all, I am trying to find a clean way (without using raw SQL) to do this: SELECT * FROM table WHERE user_id = 123 AND (role_id IN (1,2,3,4) OR role_id IS NULL) So I always need to check the user_...
221 Views
1 Replies
11-21-2023, 08:42 AM
sjender
    Thread: DataException: There is no data to update after using save()
Post: RE: DataException: There is no data to update afte...

I was wondering if there is already a solution for this (unwanted) behaviour? I am facing the same issues. My users often just click save without actually saving anything. I don't want to 'Whoops'...
2,703 Views
10 Replies
11-14-2023, 09:22 AM
sjender
    Thread: restrict query in callback
Post: RE: restrict query in callback

I've looked into that.... But how would I fit that into a callback function in the Model? I don't want to use the WHEN method on every insert query, I would like to centralize it in the model
399 Views
3 Replies
09-12-2023, 06:57 AM
sjender
    Thread: restrict query in callback
Post: restrict query in callback

Hi, I want to do some checks prior to some queries in the model. In the $beforeUpdate and $beforeDelete callback I append the query by  PHP Code: -- $this->builder()->where('id', null); -- when the...
399 Views
3 Replies
09-12-2023, 06:39 AM
sjender
    Thread: Append all SELECT queries with an extra WHERE in model
Post: RE: Append all SELECT queries with an extra WHERE ...

Yes, got it... What is, in your opinion,  the best way to get the USER_ID into this method... PHP Code: --     protected $beforeFind = ['userSpecific'];         protected function userSpecific()...
474 Views
4 Replies
09-11-2023, 08:22 AM
sjender
    Thread: Append all SELECT queries with an extra WHERE in model
Post: RE: Append all SELECT queries with an extra WHERE ...

Thanks. I will probably need beforefind then. I see how I can alter the query data, but not the query itself. Does the manuals have an example for that as well?
474 Views
4 Replies
09-10-2023, 10:21 PM
sjender
    Thread: Append all SELECT queries with an extra WHERE in model
Post: Append all SELECT queries with an extra WHERE in m...

Hi, Is there a way in CI 4 to have ALL the SELECT (find/findall) queries done by a specific model to append by an extra WHERE condition? In this case I want 3 models to do an extra: WHERE user_id = 12...
474 Views
4 Replies
09-10-2023, 11:55 AM
sjender
    Thread: connect to database mid-script
Post: RE: connect to database mid-script

Can I run another cli command from this cli command. Then I can put this migration in the second one. Then the .env should be loaded when runnning the second one.
864 Views
7 Replies
08-14-2023, 10:50 PM
sjender
    Thread: connect to database mid-script
Post: RE: connect to database mid-script

In this particular case the password should be empty, it's a local XAMP install. I have tried it with another user and pass, results are the same.
864 Views
7 Replies
08-14-2023, 11:28 AM
sjender
    Thread: connect to database mid-script
Post: RE: connect to database mid-script

I'm afraid that doesn't work. Here's what I did... PHP Code: --         $config = [             'hostname' => $dbHost,             'username' => $dbUser,             'password' => $dbPass,     ...
864 Views
7 Replies
08-14-2023, 06:30 AM
sjender
    Thread: custom validation rule fails
Post: RE: custom validation rule fails

I have placed it in \Custom\CustomValidationRules.php And added that class in The validation config as well
943 Views
4 Replies
08-13-2023, 03:26 AM
sjender
    Thread: connect to database mid-script
Post: connect to database mid-script

Hi, I have created a CLI command which sets up the database. The user is asked for DB credentials. PHP Code: --         $dbHost = CLI::prompt('Database host', 'localhost');         $dbName = CLI:...
864 Views
7 Replies
08-13-2023, 03:24 AM
sjender
    Thread: custom validation rule fails
Post: RE: custom validation rule fails

I think I already know why this is failing.... Can this be the case because the validator only has access to the primary key and CHANGED values? In this case the PARENT_ID is not changed, so it might...
943 Views
4 Replies
08-08-2023, 06:29 AM
sjender
    Thread: custom validation rule fails
Post: custom validation rule fails

Hi all, I have this strange behaviour in my custom validation rule. In my model I have this validation: PHP Code: --     protected $validationRules = [         'name'    => 'is_double_unique[categori...
943 Views
4 Replies
07-14-2023, 06:30 AM
sjender
  Wink Thread: Programmaticaly clear webpage cache
Post: RE: Programmaticaly clear webpage cache

Thanks, Solved it by doing: PHP Code: -- @unlink(WRITEPATH.'/cache/'.md5(base_url($slug))); -- Whenever I update a page
989 Views
9 Replies
06-29-2023, 11:51 AM
sjender
    Thread: External redirects
Post: External redirects

Hi, I would like to have an external redirect to my payment provider. So I tried using: PHP Code: -- $this->response->setHeader('Location', $payment->getCheckoutUrl()); -- This doesn't work. Just a ...
391 Views
1 Replies
06-29-2023, 08:30 AM
sjender
    Thread: Programmaticaly clear webpage cache
Post: RE: Programmaticaly clear webpage cache

I understand. But how does CI knows which file to render? The filenames are random.
989 Views
9 Replies
06-29-2023, 04:09 AM
sjender
    Thread: Programmaticaly clear webpage cache
Post: RE: Programmaticaly clear webpage cache

Thanks. One last question. Is there some sort of table somewhere which matches the cache file with the right url? I assume CI doesnt loop through all the cached files to see which one to use.
989 Views
9 Replies
06-29-2023, 01:12 AM
sjender
    Thread: Programmaticaly clear webpage cache
Post: RE: Programmaticaly clear webpage cache

For when the content changes before cache expiry
989 Views
9 Replies
06-29-2023, 12:35 AM
sjender

Theme © iAndrew 2016 - Forum software by © MyBB