Welcome Guest, Not a member yet? Register   Sign In
  Controller Constructor Parameter init
Posted by: jonsmith1982 - 09-15-2022, 09:10 AM - Replies (2)

Hi,
I would like to know if it is possible to init the controller with route parameter issued to each method within the controller? Sorry if this is stated in the documentation, I have read through it quite throughly and haven't come across a specific answer to this but could i possibly instantiate a controller class with a routing parameter set class wide, such as...

Code:
__constructor(private int $event_id) {}

rather than having to set... in each method...
Code:
$this->event_id = $event_id;

Is this possible or not?
Thanks in advance


  Redirect - route cannot be found while reverse-routing.
Posted by: groovebird - 09-15-2022, 08:10 AM - Replies (7)

Hi,

what does this message mean? in my routes there is a route

The call of redirect($route) is not working but the call of $this->response->redirect('/' . $route) is working. What is the correct use of the redirect function?


  Codeigniter session bugging out with ajax calls
Posted by: JernalinSadhoo - 09-15-2022, 05:40 AM - Replies (1)

My CodeIgniter app uses the session library and saves data to the DB.

I've been having some problems where blank sessions are created after a certain ajax call.

Upon investigating, it seems that there were 2 simultaneous functions calls that fired off that require a session validation. One would fail and the other would be fine.

I was able to fix this by not having them fire off simultaneously. But I still don't understand the REASON why it fails. Does it have to do with one call updating the user cookie and the 2nd call invalidating? Or maybe when reading the DB it dies somehow?

I looked over the Session core class a bit and have not found any clues to the cause.

If any one had the same problem before I would appreciate any advice on how to debug or what the cause is.

Thanks!


  text input truncated in bootstrap modal
Posted by: SohamMaoor - 09-15-2022, 05:25 AM - Replies (2)

I am using modal to make input text for update a field in CodeIgniter 4, but the text truncated into a smaller(narrower) text. The code in modal (inside sertifikat.php) is :

<div class="row">
  <div class = "mb-3 row">                                               
      <div class = "m-1 row">
        <label for="kode_ta">Kode TA</label>
        <div class = "col-sm-3">
            <input type="text" class="form-control" name="kode_ta" id="kode_ta" value=<?= $v->kode_ta; ?>>                                 
        </div>               
      </div>

    <div class="mb-3">
        <label for="sertifikat">Sertifikat</label><?= $v->sertifikat; ?>
        <input type="text" name="sertifikat" id="sertifikat" class="form-control" value=<?= $v->sertifikat; ?> required>     
    </div>
                                   
    <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
      <button type="submit" class="btn btn-primary">Simpan</button>
    </div>
  </div>
</div>
I have changed to use object model (protected $returnType = 'object'Wink, but basiccaly the same with array mode, and the result is the same. When I trace, not all field inside the text field, below is the picture when I inspect it : enter image description here

the value should be "Certified International personel assessor (cipa) oleh pt. quantum hrm international tahun 2020", but it show only "Certified" in bootstrap modal text field. When I run the program


  CRON jobs with go daddy hosting
Posted by: MariOkudoduma - 09-15-2022, 05:07 AM - No Replies

I'm using CodeIgniter as my framework and I want that every minute, alert will appear on my website. (This code are just for testing... My main code for cron have queries.)

This is my controller:

<?php
class alert extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->view("alert_view.php");
    }
   
    public function index()
    {
        $this->load->view("alert_view.php");
    }

}

?>
And This is my View:

<script>
    alert("SCHEDULED ALERT EVERY MINUTE");
</script>


  Displaying Div Based on Dropdown Selection in CodeIgnator Using Jquery
Posted by: HumeleJotesane - 09-15-2022, 04:40 AM - No Replies

I'm trying to display specific divisions based on a dropdown selection here, In my example,, I have two different dropdown options followed by two different divs. I want to show only one of these two divs based on the selected value and keep the other divs hidden.

For example, If Option 1: House Inspection is selected, then the content in div class="house" should be displayed.

PHP

<!-- PHP CodeIgniter Render Select Instead of HTML Select-->
<div class="col-md-12" >
                            <?php
$subject = [0 => ["id" => "House", "name" => _l("House Inspection") ], 1 => ["id" => "Plot", "name" => _l("Plot Inspection") ], "name" => _l("Farm House Inspection") ]];

$value = isset($subject) ? $disscussion->subject : "";
echo render_select("subject", $subject, ["id", "name"], "Inspection Type:", $value);
?>
                        </div>

                        <div class="house">
                          <?php echo render_textarea('house', 'project_discussion_description'); ?>
                        </div>

                        <div class="plot">
                          <?php echo render_textarea('plot', 'project_discussion_description'); ?>
                        </div>


    <script>
            jQuery(document).ready(function($){
            $('select[name=subject]').change(function () {

            // hide all optional elements
            $('.house').css('display','none');
            $('.plot').css('display','none');


            $("select[name=subject] optionConfusedelected")
            .each(function () {
                if($(this).val() == "House" || "Plot") {
                    $('.subject').css('display','block');
                } else if($(this).val() == "House") {
                    $('.house').css('display','block');
                } else if($(this).val() == "Plot") {
                    $('.plot').css('display','block');
                }

              });
              });
            });
    </script>


  Choosing a chained select option with jquery using Codeigniter
Posted by: JiwanFilembar - 09-15-2022, 04:33 AM - No Replies

I'm not much good at jquery and ajax, and I'm now having difficulties on a select box. I use CI and My code is below.

Another select box "category" data will be show according to the "brand". How can I carry data from "brand" and show data in "category" with jquery?

View

<select name="brand" class="form-control" id="brand" required>
    <?php
        if($items) {
            foreach($items as $key) {
    ?>
    <option value="<?php echo $key->brand_id ?>">
        <?php echo $key->brand_name ?>
    </option>
    <?php
            }
        }
    ?>
</select>

<select name="category" class="form-control" id="category" required>

</select>
Ajax

<script>
    $(function() {
        $("#brand").on('change', function() {
            var brand = $(this).val();
            $.ajax ({
                type: "post",
                url: "<?php echo base_url(); ?>receiving/showCategory",
                dataType: 'json',
                data: 'brand='+brand,

                success: function(msg) {
                    var options;
                    for(var i = 0; i<msg.length; i++) {
                        options = '<option>'+msg.category[i].category_name+'</option'>;
                    }
                    $('#category').html(options);
                }
            });
        });
    });
</script>
Controller

function showCategory() {
    $brand_id = $this->input->post('brand');
    $data['category'] = $this->item_model->category($brand_id);
    echo json_encode($data);
    }
My category table contains: category_id, category_name, brand_id.


  CodeIgniter to run from a subdirectory of another codeigniter installation
Posted by: DevinPomsilina - 09-15-2022, 04:13 AM - No Replies

I am trying to find a way to run CodeIgniter from a sub-directory of another CodeIgniter installation. The CI from the sub-directory would be for testing and the main one is the live site. Anyone could advice on this or any other better approach ?


  Codeigniter 4 Multisite
Posted by: DeepMohinman - 09-15-2022, 03:29 AM - No Replies

I have installed Codeigniter 4 on Raspbian and everything seems to be working fine. My web directory is /var/www/html Inside there are two folders containing two different Codeigniter-4 apps that I would like to invoke with:

blue.ddns.net -> /var/www/html/blue/public/index.php
black.ddns.net -> /var/www/html/black/public/index.php
So I'm creating a .htaccess file to put in the folder /var/www/html/ to handle the two requests

Well, I'm still at step 0 because I can't get the .htaccess file to work properly.

Below I attach a copy of the file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /var/www/html
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ blue/public/index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
The Rewrite module is activated the error that appears in /var/log/apache2/error.log is:

/var/www/html/.htaccess: Expected </IfModule> before end of configuration, referer: https://blue.ddns.net/


  Calculate PATIENTS age based on two dates stored in TABLE using Codeigniter
Posted by: optic4predator1 - 09-15-2022, 02:23 AM - Replies (2)

I'm working on a college project using Codeigniter and I want to display the following data by showing the number of data in real time. so i would like to calculate the age of patients based on two dates, birthdate date and registration date, I would like to know the age of the patient at the time of treatment so for this i have a TABLE named THE_PATIENT which contains id, patient_name, date_of_birth, abou_patient, created_at and a TABLE named MEDICAL_INTERVENTION which contains id, patient_id, disease_type_id , created_at. So i would like to display the total of MEDICAL_INTERVENTIONS recorded and JOIN the THE_PATIENT Table, calculate age of patients from date_of_birth to created_at, and add cases if age between 1y to 15y range = kid , else if age between 16y to 70y range = adult , else if age over 70 range = old_adult , after geting data i want to group_by age range and display it in my view. Any help will be appreciated Thank you for your assistance, my respects.

Code:
class My_model extends CI_Model {
   
        function get_medical_intv_by_patients_age_range() {
            $q = $this->db->select(' medical_intervention.patient_id, the_patient.patient_name, COUNT(medical_intervention.patient_id) as total_medical_interventions, DATEDIFF (YEAR, the_patient.date_of_birth , the_patient.created_at) AS AGE, CASE WHEN AGE BETWEEN  1 to 15 THEN kid END AS patient_age_range_1, CASE WHEN AGE BETWEEN  16 to 70 THEN kid END AS patient_age_range_2, CASE WHEN AGE > 70 THEN kid END AS patient_age_range_3,  ')
                          ->from('medical_intervention')
                          ->join('the_patient', 'medical_intervention.patient_id= the_patient.id', 'left')
                          ->group_by('patient_age_ranges')
                          ->get();
              return $q->result();
          }
    }


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
using define in a SQL sta...
by kenjis
2 hours ago
How do you View Cells?
by michalsn
8 hours ago
can temporary tables be u...
by richb201
11 hours ago
url encode
by donpwinston
Yesterday, 08:58 AM
PHP 7.4.32. This is a sec...
by InsiteFX
Yesterday, 03:57 AM
$builder->getCompiledSele...
by MikiStoni
Yesterday, 02:48 AM
Introducing serverless Co...
by captain-sensible
Yesterday, 01:16 AM
builder question when usi...
by InsiteFX
Yesterday, 12:33 AM
Chrome returns "This page...
by InsiteFX
Yesterday, 12:31 AM
under maintenance
by superior
09-30-2022, 04:15 AM

Forum Statistics
» Members: 42,979
» Latest member: splicingmachine
» Forum threads: 75,504
» Forum posts: 367,675

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB