Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14353 articles
Browse latest View live

trouble with the forum

$
0
0
I am trying to search for an old response to one of my queries regarding using temporary files in SQL. The search feature on this forum seems to be broken. I think it was InsiteFX who sent me a link on how to use temporary files in SQL. But I can't get the search feature to work nor can I send a direct email to InsiteFX. Can anyone point me to the link he suggested?

Language problem in Production

$
0
0
Hi!

I am building a web app and everything works on localhost. I deployed on aws today (for the first time) and the localization does not work anymore. The page just renders the strings for the lang() function, e.g. 'App.Menu.Proejcts' instead of 'Projects' in different languages. intl extension is loaded on the server (this is from phpinfo):
intl
Internationalization support
enabled
version 1.1.0
ICU version 50.2
ICU Data version 50.2
ICU TZData version 2018e
ICU Unicode version 6.2


php 7.2.33

Language files are in place, they are chmoded to 755 (just to be sure they are visible to the app). What could be wrong? Nothing in the logs...

Thanks in advance!
Angel

Brand new youtube series about Codeigniter 4

$
0
0
Hi guys, I've been making a few youtube videos about Codeigniter 4.

Today I published the first video on the final part of these series. On it its just a simple codeigniter install via composer but the purpose of this video is to create a contact manager. This will make me go around and talk about subject like:

- Authentication
- Form Validation
- Model events
- CRUD Models
- Database connections
- views and layouts
- Routing

All the basic things that one needs to work.

Here's the first video.

https://www.youtube.com/watch?v=cUFS9Vm9...=emb_title

If anyone has any recommendations about the project please tell me. Smile

[CI4] Toolbar DB Query And Event Duplication

$
0
0
Hi everybody.
I'm relatively new with the CI4, I've been learning it as I go and to be honest loving the changes so far.

My DB Queries are happening twice, no matter where they're executed from.
[Image: screenshot-from-2020-10-16-02-34-51.png]

these queries are being executed from several different files.
the function which runs the query is a helper as follows:
PHP Code:
function getOption(string $key)
{
    return model("OptionsModel",TRUE)->getOption($key);


and the `getOption()` function inside OptionsModel is as:
PHP Code:
public function getOption(string $key){
        if(isset(self::$loadedOptions[$key]))
            return self::$loadedOptions[$key];

        $row $this->select('option_value')
            ->where("option_key",$key)
            ->get()
        ->getRow();

        if(!$row)
            return false;

        self::$loadedOptions[$key] = $row->option_value;

        return $row->option_value;
    
Even though these functions themselves are not the problem, I wanted to explain anyways.
no matter how the query is being executed, the CI4 toolbar is always recording two of each SELECT query.
my inserts are fine and are happening only once.

and also my Events are happening twice as well.
Meaning having the following code in a view file:

PHP Code:
\CodeIgniter\Events\Events::trigger('TEST'); 
and having the following code in the Events.php
PHP Code:
Events::on('TEST', function () {
 echo 
"ON TEST EXECUTION.";
}); 
would produce "ON TEST EXECUTION.ON TEST EXECUTION." upon triggering TEST in view file.

if anyone can point me to the right direction so I can troubleshoot this it'd be greatly appreacated.

Entity class not working on 2 module

$
0
0
hi all,

i recently implement entity to my project, i successfull setup it to work with the backend module, but when i call that model in the frontend module, it does not return an entity object, i return the normal object. Here is my project structure and code

my folder structure 
[Image: eb-err-entity.png]

when i run and debug the code in acp module
[Image: eb-err-entity-2.png]
as you can see, i got my post item return successfully in entity object

but when i call it in my site module
[Image: eb-err-entity-1.png]
it does not return entity object but a normal object, does any one have this problem? or i missing something?

Codeigniter 4 license?

$
0
0
Hi,
Wondering if I made something with CI4, can I sell it?, I found someone selling product based on CI3 but is it also works same with CI4?, or is there any documentation I can read?


I'm trying to search the forum but seems there's an error:
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:145 - Table './jimparry_forum2/fx_searchlog' is marked as crashed and should be repairedQuery:SELECT * FROM fx_searchlog WHERE uid='0' AND ipaddress=X'a29ea58c' AND dateline > '1602825269' ORDER BY dateline DESC
Please contact the MyBB Group for technical support.

To convert MySQL database structure into CodeIgniter 4 Database Migrations

$
0
0
According to the guide here: https://codeigniter.com/user_guide/dbmgm...ation.html, migrations are a convenient way for you to alter your database in a structured and organized manner. 

It is great, but only when you have a brand new database to develop. What if some databases have already developed? I can see the potential of this migration feature as it can manage the database version much better. But it is kinda hard for me to use it when I already have a database structure. Indeed, some people may prefer using the old way to develop the MySQL database first. So it would be best if there is a conversion tool to convert the MySQL database structure into CodeIgniter 4 Database Migrations. I know it may be hard but please consider this feature as it can greatly enhance the usability of the CodeIgniter Migrations.
Thank you.

Helper - Call to undefined function

$
0
0
Hi All,

I'm new to CI (just started this week).

I am trying to get my own custom helper to work, but I keep getting 'Call to undefined function' errors.

Here's my code:

app/Helpers/build_page.php
PHP Code:
<?php

function tester(){
    return "test";


app/Controllers/News.php (snippet)
PHP Code:
public function index()
    {
        helper('build_page');
        echo tester(); 

As read in the manual I guess this should work?
But I keep getting:

Call to undefined function App\Controllers\tester()

What am I missing here.

PostgreSQL forge on default CURRENT_TIMESTAMP error

$
0
0
Hi,

Code:
            'created_on'    =>  [
                'type'  =>  'TIMESTAMP',
                'default'   =>  'CURRENT_TIMESTAMP'
            ]

i've tried with and without quote for CURRENT_TIMESTAMP.
But both show error when i run the code to create a table by using forge.

i saw this issue was highlighted during CI 3 but back then i never use forge to setup my db.

Please assist.

I've read the documentation related to DB topic but nothing mention about this default on timestamp.
im using CI 4.0.3 with PosgreSQL.

Very Simple Auth Helper

$
0
0
PHP Code:
<?php

    
/*
        * Base Auth - Helper
        - register
        - login
        - logout
        
        * Table: ci_users
        - id
        - username
        - password_hash
    */

    
function register($username$password)
    {
        
$db      db_connect();
        
$builder $db->table('ci_users');
        
$arrW    = ['username' => $username];
        
$users   $builder->getWhere($arrW1);
        if (
count($users->getResult()) == 1) {
            return [
                
'status' => false,
                
'code'   => 'ExistUsername'
            
];
        }
        
        
$arrA = [
            
'username'      => $username,
            
'password_hash' => hashPassword($password)
        ];
        
$builder->insert($arrA);
        
        return [
            
'status' => true,
            
'code'   => 'Success'
        
];
    }
    
    function 
login($username$password)
    {
        if (
session()->appUID 0) {
            return 
true;
        }
        
        
$db      db_connect();
        
$builder $db->table('ci_users');
        
$arrW    = [
            
'username'      => $username,
            
'password_hash' => hashPassword($password)
        ];
        
        
$users $builder->getWhere($arrW1);
        if (
count($users->getResult()) == 1) {
            
$row $users->getRow();
            
session()->set([
                
'appUID'     => $row->id,
                
'appUSN'     => $username,
                
'appIsAdmin' => ($username == 'admin' true false)
            ]);
            
            return 
true;
        }
        
        return 
false;
    }
    
    function 
logout()
    {
        
session()->remove([
            
'appUID',
            
'appUSN',
            
'appIsAdmin'
        
]);
    }
    
    function 
users()
    {
        if (
session()->appUID 0) {
            
$db      db_connect();
            
$builder $db->table('ci_users');
            
$arrW    = ['id' => session()->appUID];
            
$users   $builder->getWhere($arrW1);
            if (
count($users->getResult()) == 1) {
                return 
$users->getRow();
            }
        }
        
        return 
null;
    }
    
    function 
hashPassword($string)
    {
        
$aConf  config('App');
        
/*
            Example:
            $aConf->authKey = 'a#C';
            $aConf->authIv  = '@fB';
        */
        
$pass   false;
        
$method "AES-256-CBC";
        
$key    hash('sha256'$aConf->authKey);
        
$iv     substr(hash('sha256'$aConf->authIv), 016);
        
$pass   base64_encode(openssl_encrypt($string$method$key0$iv));

        return 
$pass;
    }
    
    function 
is_logged()
    {
        return (bool)
session()->appUID;
    }
    
    function 
is_admin()
    {
        return 
session()->appIsAdmin;
    }
    
    function 
is_username()
    {
        return 
session()->appUSN;
    } 

Connect to PostgreSQL DB with DSN and SSL Certificate

$
0
0
I currently use the database configuration using array, in a simple way.
But I will need to migrate to a PostgreSQL database that requires ssl (required) mode and also has a CRT certificate.

How do I do this type of configuration in CodeIgniter 3?

I tried to remove the entire array and set $db ['default'] ['dsn'] = 'postgresql://your_username:your_password@ip:5432/database_name?sslmode=require' but returns You have not selected a database type to connect to.

Connecting to SQL Server database

$
0
0
I have some database connections in database.php that work fine. I want to create a connection on the fly without going through database.php because I don't know what the database will be until I connect.

Previously I could use $dbconn=mssql://username@instance/dbname

Then use $seldb=$this->load->database($dbconn,true);

Can I assume that by doing mssql it is trying to use the old mssql connection? It fails with an error:

Type: Error

Message: Call to undefined function mssql_connect()

I don't see anything in my code explicitly referencing mssql_connect. Any help would be appreciated. 

How to show Custom View Error 429 Throttle

I Published a New Project named ShortApp

$
0
0
I made a simple project as a weekend project. In this project, you can redirect to more than one platform over a single link.
For Example, you have iOS, Android apps. These are the same apps.

You can normally share both links. But with this application, you can redirect to the application link according to the device at a time.
You can also share a QR code for your single link.

I used CI4 for this project.

It isn't open-source yet.

more info: https://www.shortapp.link/

CodeIgniter 4 on VestaCP

$
0
0
Hi everyone!

I use VestaCP to serve my websites. I'm using nginx and php-fpm using socket. Anyway when you use CI3 template, your CI4 project won't work.

To solve this problem copy your CI3 project templates and change uri location.

I use Centos7;

1-) Go to templates location

Code:
cd /usr/local/vesta/data/templates/web/nginx/php-fpm

2-) copy codeigniter3.tpl and codeigniter4.stpl

Code:
cp codeigniter3.tpl codeigniter4.tpl
cp codeigniter3.stpl codeigniter4.stpl

3-) Edit ci 4 templates like that;

codeigniter4.tpl and codeigniter4.stpl

Code:
server {
    listen    %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index    index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    location / {
        try_files $uri $uri/ /public/index.php;

and find the htaccess|httpasswd in the same file;

PHP Code:
    location ~* "/\.(htaccess|htpasswd|env)$" {
        deny    all;
        return  404

We added env after htpasswd. Because dotenv file shouldn't be downloadable.

4-) Rebuild your web

[Image: Screenshot-from-2020-10-17-21-12-55.png]

5-) Change your template in your project

[Image: Screenshot-from-2020-10-17-21-14-35.png]

That's all. I hope this will help you.

Vue like components in PHP/Codeigniter 4

$
0
0
Hi All, 

Starting up a new CI4 project just coming out of a Vue and wordpress site, in vue i can use components in wordpress i can use blocks that gets passed in user fields which i can react too in my frontend. 

I think it would be nice if i could create the same kind of reuseable components in CI4. 
Imagine i have a view file that displays an image + text block. 
Would it be possible to pass params to the view file i can then catch in the corresponding file, Ideally it would look like this : 

PHP Code:
// About page
<?php echo view('parts/header'); ?>

<?php echo view('component/img_text', {fliptrue})); ?>
<?php 
echo view('component/text', {bgtealcolumns4})); ?>

<?php echo view('parts/footer'); ?>

Castopod (podcast hosting platform) chose CI4

$
0
0
Hi all,

We are developing Castopod, an open-source podcast hosting solution for everyone.

I chose CI4 because I wanted a PHP framework, light but powerful.
As we released the an early alpha, I must say that we are very happy with CI4.

If you want to know more about Castopod, please go this way: https://castopod.org/

Ben.

Codeigniter where not exists does not work

$
0
0
I'm working on Codeigniter project and came across a problem. I would like that my function on my model to bring me the data from the POST table, where POST_ID in CATEGORY Table is not null, without joining the table, so (do not bring back the data whose POST_ID in CATEGORY table not exists). so i tried this method how can i get this result?

Code:
code: // MyModel

function get_data() {
   
   
    $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';

    if ($id != null) {
        $this->db->where('ID',$id);
        $result =  $this->db->select('POST.ID,POST.DATE,'
        . ' TYPE.Post_Type P_TYPE,)
        ->join('TYPE', 'POST.TYPE_ID = TYPE.ID', 'left')
        ->order_by('POST.ID', 'DESC')
        ->where_in('POST.Post_Type  = type_1, type_2')
        ->where("NOT EXISTS(SELECT POST_ID FROM CATEGORY WHERE POST.ID=CATEGORY.POST_ID )", FALSE)
        ->get('POST');
    }
    return $result;
}

Thank you for help

help! Internal Server Error on initial install of CI4!

$
0
0
I uploaded everything from the downloaded Ci4 archive, being sure that "public" is my root.  But when I tried to load the home page, I get this:

Code:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Web Server at theluridmacabre.com

Shouldn't it being something asking about setting up or whatnot?

Here's my associated error log:

Code:
[Mon Oct 19 00:56:05.001007 2020] [ssl:warn] [pid 21369] AH01909: theluridmacabre.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Oct 19 00:56:06.002122 2020] [ssl:warn] [pid 21370] AH01909: theluridmacabre.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Oct 19 01:05:09.940921 2020] [core:alert] [pid 32265] [client 66.115.189.206:62161] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option All not allowed here
[Mon Oct 19 01:05:56.994195 2020] [core:alert] [pid 7763] [client 66.115.189.206:62183] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option All not allowed here
[Mon Oct 19 01:07:11.583640 2020] [core:alert] [pid 7778] [client 66.115.189.206:62220] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option FollowSymlinks not allowed here
[Mon Oct 19 01:07:14.042305 2020] [core:alert] [pid 32062] [client 66.115.189.206:62222] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option FollowSymlinks not allowed here
[Mon Oct 19 01:07:14.390029 2020] [core:alert] [pid 32186] [client 66.115.189.206:62223] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option FollowSymlinks not allowed here, referer: https://theluridmacabre.com/
[Mon Oct 19 01:09:36.083061 2020] [core:alert] [pid 32686] [client 66.115.189.206:62295] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option All not allowed here
[Mon Oct 19 01:09:54.599955 2020] [core:alert] [pid 32702] [client 66.115.189.206:62306] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option All not allowed here
[Mon Oct 19 01:09:54.856387 2020] [core:alert] [pid 32735] [client 66.115.189.206:62309] /var/www/vhosts/theluridmacabre.com/public/.htaccess: Option All not allowed here, referer: https://theluridmacabre.com/media/img/icon.png

Help!

"Sophisticated" Between

$
0
0
Hello.
In my company, there are lots of project that have their own start date and end date. I want to know what project are now between two dates. But the situation is not simple. I use mysql. For example, i want to know what projects are now between October 5 and October 30. It is easy to get it , just using query between , since one of the start date or end date is between Oct 5 and Oct 30.

But the problem is,if there are project start date Sept 1 and end date Dec 10...it will not get detected because the search form is between is Oct 5 and Oct 30.
Because in my company, if i search what projects are between Oct 5 and Oct 30, that project started 1 Sept and ends Dec 10 should be result too.


Is there any other command in mysql that between that allow us to search dates that are going through it?

I hope you undertand my languange. Thanks
Viewing all 14353 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>