Welcome Guest, Not a member yet? Register   Sign In
Search Results
    Thread: Update multiple rows with where condition
Post: Update multiple rows with where condition

Hi, I want to update all rows in the database which meet a certain condition. PHP Code: -- $this->vatRatesModel->update(['default', 0], ['site_id', $this->site->id]); -- But this doesn't work. Wh...
477 Views
1 Replies
08-28-2024, 06:56 AM
sjender
    Thread: Custom validation rule, variables on Model
Post: RE: Custom validation rule, variables on Model

So if I equip all my models with: $updateOnlyChanged = false; $cleanValidationRules = false; It should be OK right?
1,098 Views
5 Replies
05-28-2024, 06:51 AM
sjender
    Thread: Custom validation rule, variables on Model
Post: RE: Custom validation rule, variables on Model

Thanks, that was it. The docs states a warning: "This is to avoid validation errors when updating only some fields.". But in which scenario would 'false' for $cleanValidationRules trigger a vali...
1,098 Views
5 Replies
05-28-2024, 12:02 AM
sjender
    Thread: Custom validation rule, variables on Model
Post: Custom validation rule, variables on Model

Hi, I have created a custom validation rule, it's like 'is_unique', but with an extra value... So I can not only check whether a name already exists in the database, but I can check if a user already...
1,098 Views
5 Replies
05-24-2024, 06:46 AM
sjender
    Thread: extend url_to helper
Post: extend url_to helper

Hi, I would like to extend the url_to() helper function. This is what I did... PHP Code: --
1,234 Views
2 Replies
04-22-2024, 07:01 AM
sjender
    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...
897 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_...
607 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'...
7,651 Views
13 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
977 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...
977 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()...
1,318 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?
1,318 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...
1,318 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.
2,150 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.
2,150 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,     ...
2,150 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
1,960 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:...
2,150 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...
1,960 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...
1,960 Views
4 Replies
07-14-2023, 06:30 AM
sjender

Theme © iAndrew 2016 - Forum software by © MyBB