Welcome Guest, Not a member yet? Register   Sign In
  Option to translate uri to camel case
Posted by: massimiliano1.mancini - 04-29-2025, 10:37 AM - Replies (3)

Hi All,
I'm currently using improved auto-routing, so the option to convert URIs to camelCase caught my attention. It was introduced in version 4.5.0 and enabled by default starting from version 4.6.0. I had to disable it to avoid breaking my project's code, but I'm seriously considering refactoring the code to make use of it.
The documentation notes that "The option to disable 'Translate URI To CamelCase' exists only for backward compatibility. We don’t recommend to disable it." — but the reasons behind this recommendation aren't entirely clear to me.
Before diving headfirst into the refactor, I'd like to hear your thoughts on the pros and cons of enabling this option.
Thanks in advance for any suggestions, advice, and opinions!


  How use MATCH(action) AGAINST(?)
Posted by: motoroller - 04-28-2025, 02:46 PM - Replies (4)

How use MATCH(action) AGAINST(?) in Query Builder Class
i have found only like mode


  How to refer to 'session' in my code
Posted by: PaulC - 04-28-2025, 05:05 AM - Replies (4)

Hi Team,
Chugging my way through the 3->4 migration guide, I did as suggested and changed all my old $this->session calls to $session (and all the slightly different methods).
I then wondered how/where to initialise it as the superglobal is no more and v3 autoloading has been "improved".
Eventually I read about the BaseController and how to initialise stuff there.
However, the example in the forum (somewhere) suggests setting a private $session variable and then calling $this->session = \Config\Services:Confusedession(); in the constructor.
I think I now need to refer to the session object using $this->session.
So is is $session or $this->session?
I'm so bewildered.
cheers, Paul


  ERROR: Failed to get field data from Database
Posted by: kyanoe - 04-26-2025, 04:57 AM - No Replies

I'm creating a surveys manager feature for my website. It can create a survey, edit, and delete. It's fine for the create, but not for the edit. When I'm trying to edit the "pertanyaan" (meaning: question) and added new questions that's not exist in the database, it throws an error like this:
ERROR: Failed to get field data from database.

That's somehow, it's caused by the update batch from the edit function I created.

For more information, the things that I've inspect are:
1. The columns whether on the website or the database are already good.
2. The HTML for loading the data is also good.
3. The data sent is also correct.

Here's the full code of edit function:

PHP Code:
function editPertanyaanData($database$data)
{
  $builder $database->table('s_pertanyaan');
  $idSurvey $data['id_survey'] ?: null;
  $idPertanyaan $data['id_pertanyaan'] ?: null;
  $pertanyaan $data['pertanyaan'] ?: null;
  $jenis $data['jenis'] ?: null;
  if (!$idSurvey || !$idPertanyaan || !$pertanyaan || !$jenis) {
    return null;
  }
  if (!empty($idPertanyaan)) {
    $builder->where('id_survey'$idSurvey)
      ->whereNotIn('id'$idPertanyaan)
      ->delete();
  }
  $pertanyaanDataUpdate = [];
  $pertanyaanDataInsert = [];
  foreach ($pertanyaan as $index => $teks) {
    $jenisValue = isset($jenis[$index]) && is_numeric($jenis[$index]) ? (int) $jenis[$index] : 1;
    if (empty($idPertanyaan[$index])) {
      $pertanyaanDataInsert[] = [
        'id_survey' => $idSurvey,
        'teks' => $teks,
        'jenis' => $jenisValue,
        'is_aktif' => true,
        'urutan' => $index 1,
        'created_at' => date('Y-m-d H:i:s'),
        'updated_at' => date('Y-m-d H:i:s'),
      ];
      continue;
    }
    $pertanyaanDataUpdate[] = [
      'id' => $idPertanyaan[$index],
      'id_survey' => $idSurvey,
      'teks' => $teks,
      'jenis' => $jenisValue,
      'is_aktif' => true,
      'urutan' => $index 1,
      'updated_at' => date('Y-m-d H:i:s'),
    ];
  }
  if (!empty($pertanyaanDataUpdate)) {
    $builder->updateBatch($pertanyaanDataUpdate, ['id']);
  }
  if (!empty($pertanyaanDataInsert)) {
    $builder->insertBatch($pertanyaanDataInsert);
  }
  return $database->affectedRows() > 0;



And here's how I call it:
PHP Code:
public function editSurvey($idSurvey)
  {
    if ($this->request->getMethod() === "POST") {
      $data $this->request->getPost();
      $data['dokumen_pendukung_survey'] = $this->request->getFile('dokumen_pendukung_survey');
      $database Database::connect();
      $database->transStart();
      $data['id_survey'] = $idSurvey;
      editSurveydata($database's_survey', [
        'kode' => $data['kode_survey'],
        'nama' => $data['nama_survey'],
        'dokumen_pendukung' => $data['dokumen_pendukung_survey'],
        'status' => $data['status_survey'],
      ], $idSurvey);

      if (!$idSurvey) {
        $database->transRollback();
        $database->close();
        return;
      }
      $result editSurveydata($database's_pelaksanaan_survey', [
        'id_periode' => $data['id_periode'],
        'tanggal_mulai' => $data['tanggal_mulai'],
        'tanggal_selesai' => $data['tanggal_selesai'],
        'deskripsi' => $data['deskripsi_survey'],
        'created_at' => date('Y-m-d H:i:s'),
      ], $idSurvey);
      if (!$result) {
        $database->transRollback();
        $database->close();
        return;
      }
      $result editPertanyaanData($database$data);
      if (!$result) {
        $database->transRollback();
        $database->close();
        return;
      }
      $database->transCommit();
      $database->close();
      return alert('survey/manajemen-survey''success''Survey berhasil diupdate!');
    }

    $data['survey'] = $this->surveyModel->find($idSurvey);
    if (!$data['survey']) {
      return alert('survey/manajemen-survey''error''Survey tidak ditemukan!');
    }
    $data['pelaksanaan_survey'] = $this->pelaksanaanSurveyModel->where('id'$idSurvey)->first();
    if (!$data['pelaksanaan_survey']) {
      return alert('survey/manajemen-survey''error''Pelaksanaan survey tidak ditemukan!');
    }
    $data['periode'] = $this->periodeModel->findAll();
    $data['pertanyaan'] = $this->pertanyaanSurveyModel->where('id_survey'$idSurvey)->orderBy('urutan''asc')->findAll();
    echo view('layouts/header.php', ["title" => "Manajemen Survey"]);
    echo view('survey_kepuasan/manajemen_survey/edit_survey.php'$data);
    echo view('layouts/footer.php');
  


  Best way to add an anchor to pager links
Posted by: kcs - 04-25-2025, 05:56 AM - Replies (2)

Hi everyone,

I was interested in adding an anchor to my pager links to make sure that when users navigate through their results, they don't have to scroll back down to them, but rather stay at the same page level. Better user experience...
I thought I could add an anchor as a parameter maybe, but looking at the pager documentation, It does not look possible. 
I thought maybe I could pass a value to the template from my $viewData variable but when I tried, I got an 'undefined variable' error ; the template does not have access to my views variables?
In the end I made it work this way: I created 2 different templates, one to be used in my bookings page, with the #bookings anchor I need, one in my presentations page where there are reviews, with the #reviews anchor I need and I select the template to be used in my controller or my view.
It works but I feel there could be a better way to avoid having 2 template files where the only thing that changes is an anchor.
Can you share your thoughts on the best way to do this?


  New version of PHP: The "Right" Way is available
Posted by: FlavioSuar - 04-25-2025, 04:22 AM - No Replies

https://phptherightway.com
https://leanpub.com/phptherightway


  funny mysql issue i don't understand
Posted by: virtualgadjo - 04-25-2025, 02:01 AM - Replies (11)

Hi,
i'm running into a funny issue i can't understand with a simple query, this

Code:
$this->db->query("update table set field = NULL where id = xx");
doesn't do anything (whether the updated column is alone or aamong other cols, prepared query or not) and, of course, the field is set to be NULL by default
i must admit i do not understand at all why because pastnng exactly the same query in the phpmydamin sql tab query field it works like a charm!
(codeigniter 4.5.3)
if any of you had a lightful idea that would help me understand why my old brain is stuck Smile
have a nice day

edited just because i forgot to say it's a date field


  intermittent smtp failures with gmail
Posted by: miked - 04-24-2025, 08:57 AM - Replies (1)

CI version 3.1.13
We've seen this more than a few times where, out of the blue, sending mail thru google randomly declines to auth.  Usually about 24 hours or so later the problem resolves itself.  

No changes to my config/email.php file since Dec of '23.  

Sending 200ish emails a day will work fine for months on end, and then suddenly I human notified that emails that CI has sent are not appearing in the gmail sent mail folder.  

The CI logs show about 1 in 10 smtp failure messages like the one below.  Server is running on a DigitalOcean droplet in the SF region.  Requested help at DO as well.

How can I best troubleshoot this? 

Code:
220 [url=http://smtp.googlemail.com]smtp.googlemail.com[/url] ESMTP<uuid>.110 - gsmtp
<br /><pre>hello: 250-smtp.googlemail.com at your service, [159.65.78.78]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
</pre>Failed to authenticate password. Error: 535-5.7.8 Username and Password not accepted. For more information, go to
535 5.7.8  [url=https://support.google.com/mail/?p=BadCredentials]https://support.google.com/mail/?p=BadCredentials[/url] <uuid>.110 - gsmtp
<br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>Date: Thu, 24 Apr 2025 15:24:09 +0000

My config/email.php:

Code:
$config['useragent'] = '';
$config['protocol'] = 'smtp'; 
$config['mailpath'] = '/usr/sbin/sendmail'; 
$config['smtp_host'] = 'ssl://smtp.googlemail.com'; 
$config['smtp_user'] = '[email protected]'; 
$config['smtp_pass'] = 'passwd'; 
$config['smtp_port'] = 465; 
$config['smtp_timeout'] = 30; 
$config['smtp_keepalive'] = FALSE; 
$config['smtp_crypto'] = ""; 
$config['wordwrap'] = TRUE; 
$config['wrapchars'] = 76; 
$config['mailtype'] = 'html'; 
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = '3'; 
$config['crlf'] = "\r\n"; 
$config['newline'] = "\r\n"; 
$config['bcc_batch_mode'] = ''; 
$config['bcc_batch_size'] = ''; 
$config['dsn'] = ''; 


  JetBrains PHPverse 2025 Join the free virtual event along with community experts to c
Posted by: InsiteFX - 04-24-2025, 07:06 AM - No Replies


  Is hiring a digital marketing agency really worth it for startups?
Posted by: moana23 - 04-24-2025, 01:00 AM - Replies (2)

Hey folks,
I'm in the early stages of launching my startup and I keep hearing that working with a digital marketing agency can make a big difference in growth and online presence. But I’m not totally convinced yet—there’s a lot of conflicting advice out there.
So I wanted to ask: Has anyone here actually hired a digital marketing agency when their business was just starting out? What kind of impact did it have? Was it worth the cost?
Also, what should a startup really expect from a digital marketing agency? I’m talking realistic outcomes—not just vague promises of "more traffic."
Would love to hear any personal experiences or tips before I commit to anything. Thanks in advance!


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

Username
  

Password
  





Latest Threads
tool bar not showing
by InsiteFX
1 hour ago
Tool bar not showing
by InsiteFX
1 hour ago
Validation does not appea...
by grimpirate
9 hours ago
Block IP addresses of bad...
by grimpirate
9 hours ago
The Hidden Cost of “Innov...
by davis.lasis
9 hours ago
Override Router
by grimpirate
9 hours ago
CodeIgniter.com - Report ...
by Vikas Mehta
Yesterday, 10:30 AM
best way to store tokens ...
by ahallrod
Yesterday, 10:03 AM
Hey Now it is a time for ...
by J0shflynn
06-29-2025, 06:44 AM
Forum Anti-Spam Measures
by J0shflynn
06-29-2025, 06:43 AM

Forum Statistics
» Members: 154,228
» Latest member: gasorexsrenergy
» Forum threads: 78,434
» Forum posts: 379,704

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB