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



Search Forums

(Advanced Search)

Forum Statistics
» Members: 14,907
» Latest member: alictcklin
» Forum threads: 70,262
» Forum posts: 361,574

Full Statistics

Latest Threads
Changing the name of a vi...
Forum: Model-View-Controller
6 hours ago
» Replies: 3   » Views: 142
Hot to get ID of record i...
Forum: CodeIgniter 4 Support
7 hours ago
» Replies: 3   » Views: 53
An Error Was Encountered ...
Forum: General Help
8 hours ago
» Replies: 1   » Views: 95
CodeIgniter Fan Art
Forum: Lounge
8 hours ago
» Replies: 1   » Views: 97
Documentation not accurat...
Forum: CodeIgniter 4 Support
10 hours ago
» Replies: 1   » Views: 82
CI4: how to check DB conn...
Forum: CodeIgniter 4 Discussion
10 hours ago
» Replies: 1   » Views: 57
The requested URL was not...
Forum: Issues
11 hours ago
» Replies: 3   » Views: 95
How to catch database ope...
Forum: Model-View-Controller
Today, 07:39 AM
» Replies: 8   » Views: 284
Forum: CodeIgniter 4 Discussion
Today, 03:15 AM
» Replies: 0   » Views: 83
validation if_exist
Forum: CodeIgniter 4 Support
Today, 12:37 AM
» Replies: 1   » Views: 134

  CI4: how to check DB connection?
Posted by: Avega Soft - 10 hours ago - Forum: CodeIgniter 4 Discussion - Replies (1)

Hi evryone!!! I have small trouble with how to right way check database connection. In my case I do this way:

PHP Code:
public function checkDBConnection( array $DBConfig = [] ) : bool {

        try {

            $result false;

            if( !empty($DBConfig) ) {

                $custom = [

                    'DSN'      => $DBConfig['DNS'],
                    'hostname' => $DBConfig['hostname'],
                    'username' => $DBConfig['username'],
                    'password' => $DBConfig['password'],
                    'database' => $DBConfig['database'],
                    'DBDriver' => $DBConfig['dbdriver'],
                    'DBPrefix' => $DBConfig['prefix'],
                    'pConnect' => false,
                    'DBDebug'  => (ENVIRONMENT !== 'production'),
                    'cacheOn'  => false,
                    'cacheDir' => '',
                    'charset'  => 'utf8',
                    'DBCollat' => 'utf8_general_ci',
                    'swapPre'  => '',
                    'encrypt'  => false,
                    'compress' => false,
                    'strictOn' => false,
                    'failover' => [],
                    'port'     => $DBConfig['port'],

                $db = \Config\Database::connect($custom);

                if( $db->persistentConnect()->ping() ) {

                    // Connection was successful
                    $result true;

        } finally {

            return $result;

But I am not sure in this way. Please need advice or comment with right descision. Thanks

  Hot to get ID of record inserted using model "save()" method
Posted by: RobT - 10 hours ago - Forum: CodeIgniter 4 Support - Replies (3)

Hi guys,
I need to get (automatically generated) ID of record inserted in db using model "save()" method.

PHP Code:
$product = new Product();

if (
    echo $ID// <-- how do I get it?

I know the model contains a shared instance of Query Builder but I can't access "db->insertID()" because "db" is a protected property.
Any help?

  Documentation not accurate in Database Forge Class
Posted by: engel - Today, 05:38 AM - Forum: CodeIgniter 4 Support - Replies (1)

Hi Everyone,

I noticed something not correct on the documentation of Database Forge Class. It say there that $forge->createDatabase() returns TRUE/FALSE based on success of failure. I was testing it today and on failure, it throws an exception instead. Just an FYI.

  CodeIgniter Fan Art
Posted by: Huyen John - Today, 03:24 AM - Forum: Lounge - Replies (1)

We should have a section or this topic, where designers can post and the rest of us can download wallpapers with CodeIgniter, Codeigniter logo, stickers and other stuff like that.

CodeIgniter could also have a store, where all the profit should go in growing CodeIgniter or should be donated to a charity project.

  MS SQL Srv
Posted by: puschie - Today, 03:15 AM - Forum: CodeIgniter 4 Discussion - No Replies

i have worked on the sqlsrv implementation a bit : https://github.com/puschie286/CodeIgnite.../mssql-srv

its a very rough implementation, many functions are simply copied and adjusted to implement limits at the query beginning.

there are still a few problems that are not handled automatically:
* update, insert that contain index value data (identity column data)
* cast to int for text/varchar increment/decrement

im not sure how to implement the identity detection in a way that result not in an additional request on every update/insert

  An Error Was Encountered - Invalid DB driver ?
Posted by: jocm.aguiar - Yesterday, 11:17 PM - Forum: General Help - Replies (1)


I believe I have made all the necessary settings to work with mysql database in CI3 3.1.11 but I come across invalid drive, the server I use is Apache2, Mysql-server5.7.28, Php7.3 below follows my settings and error print:

File autoload.php, setup :

$autoload['libraries'] = array('database');

File database.php, setup :

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'    => '',
    'hostname' => 'localhost',
    'username' => 'myuser',
    'password' => 'mypass',
    'database' => 'mydatabase',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

File config.php, setup to session work with database :

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

error message -> An Error Was Encountered - Invalid DB driver ?

  Call function in model before validation
Posted by: RobT - Yesterday, 10:26 AM - Forum: CodeIgniter 4 Support - No Replies

Hi guys,
I have a model with the following validation rule.

PHP Code:
'slug'  => 'is_unique[products.slug,ID,{ID}]|alpha_dash' 

I would like to automatically generate a slug when none is provided, so I added:

PHP Code:
protected $beforeInsert = ['generateSlug'];

protected function 
generateSlug(array $data)
        if (empty(
$data['data']['slug'] = url_title($data['data']['name'], '-'true);


The problem seems that validation rules are evaluated before `beforeInsert` callback is called.

Could you help me?

  Saving data to MYSQL
Posted by: dmorgan20 - Yesterday, 10:25 AM - Forum: Model-View-Controller - Replies (1)

I have followed an online guide how to do this. But its not working. I've made some slight changes but nothing is working, help

User inputs info page:

<fieldset class="col-xs-12 col-sm-6 personal-info-wrapper">
                        <input type="hidden" id="user-id">
                        <form method="post">
                            <div class="form-group">
                                <label for="postcode">Enter Postcode Area</label>
                                <input style="font-size:12px" name="postCode" id="postcode" class="form-control required" value="e.g CF11">
                             <div class="form-group">
                                <label for="deliveryCost">Delivery Charge</label>
                                <input style="font-size:12px" name="delivery" id="deliveryCost" class="form-control required" value="e.g 5.00">
                            <button type="button" class="save-settings btn btn-primary btn-xs"
                                title="<?= lang('save') ?>">
                                <span class="glyphicon glyphicon-floppy-disk"></span>
                                <?= lang('save') ?>
                            <input type="submit" name="savePostcode" value="Save Data"/>


    /*load database libray manually
    $this->load->database();       */

    /*load Model
    $this->load->model('Settings_model');   */


    public function savedata()
        /*load registration view form*/

        /*Check submit button */


        echo "Records Saved Successfully";

    /* Insert postcodes to table*/

    function saverecords($postCode,$delivery)

    $query="insert into Postcodes values('','$postCode','$delivery')";

  The requested URL was not found on this server.
Posted by: chrisco - Yesterday, 10:24 AM - Forum: Issues - Replies (3)

I decided to make a local copy of my website so I build a web server with apache/MariaDB/php73. Also, create a virtual host for my site. The problem is that it only displays my home page and for every link that I click I get an error similar to this one:
The requested URL /за-мен was not found on this server.

Nothing is changed from the public copy of the site and everything is ok there.

Any help will be appreciated!

  validation if_exist
Posted by: aparedesv - Yesterday, 06:59 AM - Forum: CodeIgniter 4 Support - Replies (1)


this rule is correct?
'nom_anterior' => ['rules' => 'if_exist|min_length[2]|max_length[100]'],

I get this when the field isn't value:
The nom_anterior field must be at least 2 characters in length.



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.