Welcome Guest, Not a member yet? Register   Sign In
  display data in modal
Posted by: Tajar_Dobro - 4 hours ago - Replies (1)

hi firends
how can i display the data of one row in modal?
the data in table are okay but they nort show up when i click on modal of a signe row


  CI4: Code Module is showing 404 in live server (cPanel)
Posted by: ciddict - Yesterday, 01:26 PM - Replies (2)

I've added the module folder in ...\app\Config\Autoload.php

PHP Code:
public $psr4 = [
          APP_NAMESPACE => APPPATH// For custom app namespace
          'Config'      => APPPATH 'Config',
          'Blog'      => ROOTPATH 'example/Blog',
]; 

My directory:


Code:
/Home directory of main project folder
/example
    /Blog
        /Config
            /Routes.php
       /Controllers           
           /Blog.php


Routes.php


PHP Code:
namespace Config;

// Create a new instance of our RouteCollection class.
$routes Services::routes();

$routes->get('blog''blog::index', ['namespace' => 'Blog\Controllers']); 


Blog.php


PHP Code:
namespace Blog\Controllers;

class 
Blog extends \CodeIgniter\Controller {

    function index() { 
        echo "Code module";
    }




After running my_domain/index.php/blog, it's showing this error:

Code:
404 - File Not Found

Controller or its method is not found: \Blog\Controllers\blog::index

But it's working fine in my localhost server. 


  Model not using DBGroup
Posted by: smcintyr - Yesterday, 09:02 AM - Replies (3)

I searched the forums but it does not appear anyone else is having this issue.

I am using the myth-auth module to provide authentication to my system.  To keep things logically separated, I have a separate database for the authentication module and a separate database for my data.  I have configure the myth-auth module to use the 'default' database group, and I'm trying to configure CodeIgniter 4 to use another  database for the data.  Here is what I have.

.env

Code:
database.default.hostname = localhost
database.default.database = users
database.default.username = mysql
database.default.password = password
database.default.DBDriver = MySQLi

database.publications.hostname = localhost
database.publications.database = publications
database.publications.username = mysql
database.publications.password = password
database.publications.DBDriver = MySQLi

/app/Config/Database.php
PHP Code:
public $default = [
 
'DSN'      => '',
 
'hostname' => 'localhost',
 
'username' => 'mysql',
 
'password' => 'password',
 
'database' => 'users',
 
'DBDriver' => 'MySQLi',
 
'DBPrefix' => '',
 
'pConnect' => false,
 
'DBDebug'  => (ENVIRONMENT !== 'production'),
 
'charset'  => 'utf8',
 
'DBCollat' => 'utf8_general_ci',
 
'swapPre'  => '',
 
'encrypt'  => false,
 
'compress' => false,
 
'strictOn' => false,
 
'failover' => [],
 
'port'    => 3306,
 ];
 public 
$publications = [
 
'DSN'      => '',
 
'hostname' => 'localhost',
 
'username' => 'mysql',
 
'password' => 'password',
 
'database' => 'publications',
 
'DBDriver' => 'MySQLi',
 
'DBPrefix' => '',
 
'pConnect' => false,
 
'DBDebug'  => (ENVIRONMENT !== 'production'),
 
'charset'  => 'utf8',
 
'DBCollat' => 'utf8_general_ci',
 
'swapPre'  => '',
 
'encrypt'  => false,
 
'compress' => false,
 
'strictOn' => false,
 
'failover' => [],
 
'port'    => 3306,
 ]; 

/app/Models/FiscalYearModel.php
PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Model;

class 
FiscalYearModel extends Model {
  protected $DBGroup  'publications';
  protected $table "FiscalYears";
  protected $primaryKey "FiscalYearID";
  protected $allowedFields = ["FiscalYear"];

  public function getFiscalYear($fiscalYearID) {
    return $this->find($fiscalYearID);
  }

  public function getDBGroup() {
    return $this->DBGroup;
  }

Error Message
mysqli_sql_exception #1146

Table 'users.FiscalYears' doesn't exist


  Emails has exceeded the max defers and failures per hour
Posted by: ZoeF - Yesterday, 07:25 AM - Replies (2)

I have a system that is running for practicly 4 years now. But since yesterday my provider is blocking the emails send. Wich is a real pain in the but. I don't know if something has changed or if their is a update I am unaware of that might fix this issue?

Quote:This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  [email protected]
    Domain xxx.be has exceeded the max defers and failures per hour (50/50 (100%)) allowed. Message discarded.

I believe the issue lies with the provider but they claim it might be me who is sending emails in a loop. As this issue occured only a few days ago and I have not uploaded anything I strongly doubt it is me who is at fault. But I ask here just to verify I am not overlooking something.


Question Gettng 404 errors
Posted by: err0r500 - Yesterday, 06:50 AM - No Replies

This is my first time working with CI, I'm trying to upgrade from CI 2 to 3.1.11. I followed the instruction in the user guide and was able to get the main page to load the login screen. Anytime I try to login or click any other link (which checks to see if im logged in and redirects) I get a 404.

domain.com/application/base.php/controller/function
The page you requested was not found.


  Filters and $_POST (or $request post vars)
Posted by: Kaosweaver - Yesterday, 05:38 AM - No Replies

I want to automatically add variables to each incoming POST, so I thought filters would be helpful, however, I can't see a way to get to the POST vars in the filter class

PHP Code:
class Filters extends BaseConfig
{
 
 public 
$aliases = [
 
'csrf'    => CSRF::class,
 
'toolbar'  => DebugToolbar::class,
 
'honeypot' => Honeypot::class,
 'postfilter' => PostFilter::class
 ];
 public 
$globals = [
 
'before' => [
 
// 'honeypot',
 // 'csrf',
 
],
 
'after'  => [
 
'toolbar',
 
// 'honeypot',
 
],
 ];

 public 
$methods = [
 
    'post' => ['postfilter']
    ];

 public 
$filters = [];


the PostFilters class:

PHP Code:
class PostFilter implements FilterInterface
{
    public function before(RequestInterface $request$arguments null)
    {
        $_POST['Maint_Userid'] = "plugh";
        $_POST['Create_Userid'] = "plugh";
        return $request;
    }

    public function after(RequestInterface $requestResponseInterface $response$arguments null)
    {
        // Do something here
    }


I've also tried:
PHP Code:
public function before(RequestInterface $request$arguments null)
    {
        $post_request = \Config\Services::request();
        $post_request->Maint_Userid "plugh";
        $post_request->Create_Userid "plugh";
        return $request;
    
PHP Code:
public function before(RequestInterface $request$arguments null)
    {
        $request['Maint_Userid'] = "plugh";
        $request['Create_Userid'] = "plugh";

        return $request;
    
(and a few other variations of the above)

It is adding the varaibles to the RequestInterface $request (from log_messages, I see this). Even the direct $_POST didn't add it to the post vars in the controller.
Where should I be doing this (or how do I make the filters see the $_POST vars and add to them)?
Thanks.


  PHP 8 - Mailhog and CI 4.1.3
Posted by: Chroma - Yesterday, 03:23 AM - Replies (2)

I've upgraded my CI4 to the latest version (4.1.3), no real problems there, and now want to use PHP 8 for future development work. So far nothing unreasonable.

However, my mailhog installation works fine with PHP 7.4.21, but the exact same code does NOT work with PHP 8.0.8.

This is perplexing. I don't know where the error is, it seems like the intercept part that mailhog performs is not happening. The mail appears to send from the mail command correctly, but nothing shows up anywhere. It's like it vanishes into the magic bitbucket.

Any thoughts would be appreciated.


  Query builder question (CI 4 newbie)
Posted by: bastian - Yesterday, 02:18 AM - Replies (4)

Hi there
I started making my first steps with CI4 after years of experience with CI. Now I'm struggling with something that worked fine with query builder prior to CI4.
Here are two functions of a basic model:

PHP Code:
public function getThread($id$field NULL) {

 
$query $this->db->table('threads')
              ->where('id'$id)
              ->get();

 
$thread $query->getRow();

 if (
$thread == FALSE) {

    return FALSE;
 }

 
$thread->posts $this->basicModel->getPostsByThread($thread->id);

 if (
is_null($field)) {

    return $thread;
 }

 else {

    return $thread->$field;
 } 
 }


 public function 
getPostsByThread($thread_id) {

 
$query $this->db->table('posts')
              ->where('thread_id'$thread_id)
              ->orderBy('date')
              ->get();

 return 
$query->getResult();
 } 

So, when calling function getThread() CI4 return the following error caused by the line $thread->posts = …:


Quote:CodeIgniter\Database\Exceptions\DatabaseException #8
You must set the database table to be used with your query.

I guess I have to rethink using query builder. Maybe you can give me a hint.


  I can't validate array in json.
Posted by: reinaldo07 - 07-26-2021, 07:04 PM - Replies (6)

I'm not able to validate the array of items that I'm passing via json.

Here's how I'm trying:

Rules:

PHP Code:
public $createTransaction = [
        'api_key' => [
 
'label' => 'api-key',
 
'rules' => 'required'
 
],

        'date_expire' => [
 
'label' => 'Data Expiração',
 
'rules' => 'required|valid_date[Y-m-d H:m:s]'
 
],
        
        
'customer.name' => [
 
'label' => 'Nome',
 
'rules' => 'required'
 
],
        'customer.email' => [
 
'label' => 'Email',
 
'rules' => 'required|valid_email'
 
],
        'customer.external_id' => [
 
'label' => 'Id',
 
'rules' => 'required'
 
],

        'items.*.id' => [
 
'label' => 'Item Id',
 
'rules' => 'required'
 
],
        'items.*.name' => [
 
'label' => 'Nome do Item',
 
'rules' => 'required'
 
],
        'items.*.description' => [
 
'label' => 'Descrição do Item',
 
'rules' => 'required'
 
],
        'items.*.value' => [
 
'label' => 'Valor do Item',
 
'rules' => 'required'
 
],

        'amount' => [
 
'label' => 'Valor total',
 
'rules' => 'required|numeric'
 
],
    ]; 

JSON:
Code:
{
"api_key": "syPK1zJAUT",
"date_expire": "2021-07-27 00:01:00",
"customer":
{
"name": "Reinaldo",
"email": "[email protected]",
"external_id": "1"
},
"items":
[
{
"id": "1",
"name": "Notebook Dell",
"description": "Notebook Dell 4GB",
"value": "3000"
},
{
"id": "2",
"name": "Notebook Samsung",
"description": "Notebook Samsung 4GB",
"value": "3000"
}
],
"amount": "6000"
}

I pass the json normally.

PHP Code:
$json $this->request->getJSON(true);
$this->validation->run($jsoncreateTransaction); 

It does not validate only on array items, for example: in the "id" field, if only one field is correct, it passes validation.


  Codeigniter mentioned in Kinsta video
Posted by: php_rocs - 07-26-2021, 06:28 AM - Replies (2)

Check it out! https://youtu.be/8RH7n5aKP94?t=274


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

Username
  

Password
  





Latest Threads
Emails has exceeded the m...
by ZoeF
1 hour ago
Model not using DBGroup
by InsiteFX
1 hour ago
inhibiting image download
by InsiteFX
1 hour ago
display data in modal
by InsiteFX
1 hour ago
CI4: Code Module is showi...
by InsiteFX
1 hour ago
Composer package or modul...
by superior
1 hour ago
Query builder question (C...
by bastian
Yesterday, 08:19 AM
PHP 8 - Mailhog and CI 4....
by Chroma
Yesterday, 06:58 AM
Gettng 404 errors
by err0r500
Yesterday, 06:50 AM
I can't validate array in...
by reinaldo07
Yesterday, 05:55 AM

Forum Statistics
» Members: 25,724
» Latest member: lotusgarden1
» Forum threads: 73,780
» Forum posts: 360,143

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB