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

CURRENT_TIMESTAMP: different mysql-behavior phpmyadmin vs. CI

$
0
0
Hi,

We have a problem with different behavior between executing mysql-query in phpmyadmin and Codeigniter. In the same UPDATE-Query we would like do both save an old timestamp (means: "move" to an other field)  and set the new timestamp. That doesn't work with Codeigniter. Codeigniter sets both fields with the new value.

Why that?

One thing we recognize: It works with Codeigniter, If we stop using the mysql-function "ON UPDATE CURRENT_TIMESTAMP". Actual "ON UPDATE CURRENT_TIMESTAMP" is a "core-function" of our system, because we do not implement a modified=NOW() statement at all.

Code:
CREATE TABLE `test` (
  `id` int(6) NOT NULL,
  `name` char(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `modified2` datetime DEFAULT NULL,
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `test` (`id`, `name`, `created`, `modified2`, `modified`) VALUES
(1, 'Test1', NULL, NULL, '2018-11-29 11:50:39'),
(2, 'Test2', NULL, NULL, '2018-11-29 11:50:39');


in phpmyadmin
Code:
UPDATE
  test
SET
  modified2 = modified,
  modified = NOW()
WHERE
  id = 1

results (as expected):
(1, 'Test1', NULL, '2018-11-29 12:50:39', '2018-11-29 11:52:44')

in Codeigniter

PHP Code:
$this->db->query('
UPDATE
  test
SET
  modified2 = modified,
  modified = NOW()
WHERE
  id = 1
'
); 

results (not expected):
(1, 'Test1', NULL, '2018-11-29 11:52:44', '2018-11-29 11:52:44')

It should
  1. set "modified2" with the old value of "modified" (2018-11-29 12:50:39)
  2. set "modified" with the new value
How could that be?

Best,
kbs170

MySQL - Issue with SELECT & GROUP BY

$
0
0
Hello lovely CI Community,

I have a basic config MySQL 5.7 / PHP 7.0 with this DB : 
  • Pages Table 

  • Tags Table

  • Pages_Tags (Joint Table)
Query : 

Code:
$this->db->from("pages");
$this->db->select("*,GROUP_CONCAT('tags_name')");
$this->db->join('pages_tags', 'pages_tags.pages_id = pages.pages_id', 'left');
$this->db->join('tags', 'tags.tags_id = pages_tags.tags_id', 'left');       
$this->db->group_by("pages.pages_id");

and i have the following error : 

Code:
Expression #1 of SELECT list is not in GROUP BY clause and contains  nonaggregated column this is incompatible with sql_mode=only_full_group_by

So i made a lot of researches, and seems there are 2 solutions to fix it (more info here : https://dev.mysql.com/doc/refman/5.7/en/...dling.html) : 

1/ To change the SQL mode ===> I don't want to change the default config
2/ To have the same column in the SELECT & GROUP BY ===> I need a lot of columns in the SELECT and not only the ones in GROUP BY. Especially if the query is more complicated with a lot more LEFT JOIN. I need to display all theses infos.

Do you have any other solutions ? Alternative with other methods ? I'm open to anything Wink 

What i need is to get the list of pages and for each page the tags linked to, in one query.
It seems so easy but it doesn't work Big Grin 

Thanks a lot !!

bootstrap modal did not pop up after 10 records of pagination datatable in codeignit

$
0
0
Bootstrap modal did not pop up after 10 record of data table pagination. i don't know why so please help me. i had many tried to solve this but i cant understand this. I don't know idea about jquery so please give me ans.
Here is my php code:


<table id="example1" class="table table-bordered table-striped">
    <thead>
        <tr>
            <th>Sr No</th>
            <th>Title</th>
            <th>Description</th>
            <th>Status</th>
            <th>Deadline Date</th>
            <th>Add</th>
            <th>Show</th>
        </tr>
    </thead>
    <tbody>
     <?php
     $str = 1;
     foreach ($getplan as $key => $get) {
        ?>
        <tr>
            <td><?php echo $str; ?></td>
            <td><?php echo $get['title']; ?></td>
            <td><?php echo $get['description'] ?></td>
            <td><?php echo $get['color'] ?></td>
            <td><?php echo $get['end_date'];?></td>
            <td>
                <?php echo $get['members'] ?><br/>
                <a href="<?php echo base_url() . "welcome/get_member_id/" . $get['id'] ?>"<i class="fa fa-plus" aria-hidden="true"></i>Add Member</a>
            </td>

            <td>
                <input type="button" name="view" value="Show" id="<?php echo $get['id'] ?>" class="btn btn-info btn-xs view_data" />
            </td>

        </tr>
        <?php
        $str++;
    }
    ?>
</tbody>
</table>

Here is my Modal:
Code:
<div id="dataModal" class="modal fade">  
<div class="modal-dialog modal-lg">  
   <div class="modal-content">  
       <div class="modal-header">  
           <button type="button" class="close" data-dismiss="modal">&times;</button>  
           <h4 class="modal-title">Employee Tast Details</h4>  
       </div>  
       <div class="modal-body" id="employee_detail">
       </div>  
       <div class="modal-footer">  
           <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>  
       </div>  
   </div>  
</div>  

Here my script:

<script type="text/javascript">
    $(document).ready(function(){   
        $('.view_data').click(function(){  
            var employee_id = $(this).attr("id");
            $.ajax({  
                url:"<?php echo base_url('welcome/show'); ?>",  
                method:"post",  
                data:{employee_id:employee_id},  
                success:function(data)
                {  
                    $('#employee_detail').html(data);  
                    $('#dataModal').modal("show");  
                }  
            });  
        });  
    });  
</script>

Autoload a class?

$
0
0
Hi guys.

I am new to codeigniter.

I want to make my own App_Controller and extend all other controllers from this.
I want to put it in controllers folder.

But is not working.
class Welcome extends App_Controller { 
is not finding it even if they are in the same contorller?

There is no such thing as loading a file by its class name?

I looked at https://www.codeigniter.com/user_guide/l...oader.html
Looks like my only hope is to put my App_Controller in core and init that in my config or smth?

I really think there should be an autoloader to look files by class name that is a big surprise for me not to find. 
Or is there a way?

Cheers

CodeIgniter with MongoDB

$
0
0
Hi everybody here,
I want to use Nosql (MongoDB) in CI project and I want to know how to do it. Someone to help me?
And excuse for my english if you don't really understand.

Authorize.Net (net\authorize\api) Helper

$
0
0
Hello CI patrons.

I am just starting an integration for the latest Authorize.Net PHP SDK. 
I couldn't find an example for the newer net\authorize\api method, so I thought I'd start the thread here.

I am planning on this structure:
- Custom library for most of the code in 'libraries'. 
- core -> MY_Controller to store some constants.

The idea is to be able to load the library in the controller as well as call the function there.

Comments welcome if there is a better idea... otherwise, I'll post some code or questions when I have them.

CSRF protection for direct url access

$
0
0
Hi Guys,

I am new in codeigniter. Any idea how prevent direct url access.

i can make crud opration project. for "View" or "Delete" Operation i want to prevent with CSRF token.

Code:
http://localhost/user/view/5

i want to prevent this. and same a delete.

CSRF enable in config file and CSRF token work with add, edit form

i want only direct url access.

Thank you.

Codeigniter job available

$
0
0
Hello, we are looking for a Codeigniter developer. He or she should know ion auth and also should know his way around codeigniter well. We want to finish a project faster and we need an extra hand to help out.

Our timezone is GMT +3 or Moscow time.

We are a startup so any potential candidate should not expect a six figure salary just as yet. The candidate should have a business mentality and  should have an eye for detail.

Good luck.

Update app from CI3 to CI4

$
0
0
Hello,

I need someone skilled to update an app witten in CI3/Postgresql to CI4/postgres, respecting the new good practices of the latest version

After that, i will need new features on a regular basis

I am myself a "old monkey" user of CI4 so please don't apply if you are a junior dev.

We will work via a freelance platform, like upwork, peoplehour, etc..

Cheers,

Emmanuel

Delete all the index.html file "Directory access is forbidden." when using .htaccess

$
0
0
Hello,

I have got  a simple question.

After installation I saw CodeIgniter puts in each folder an index.html file with the following content:

Code:
<!DOCTYPE html>
<html>
<head>
 <title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

Can I delete these files?

I am already using .htaccess in top folder to make all directories tree completely forbidden to anyone (i.e. "Deny from all")

CodeIgniter 4.0.0-alpha.3 released :)

$
0
0
CodeIgniter-4.0.0-alpha.3 launches today, after an incredibly busy month of activity since alpha.2 [Image: smile.gif]

Huge shoutout to Lonnie Ezell for all of his hard work, and a warm welcome to Natan Felles, newest member of the core developer team.

This is a pre-release of 4.0.0. It is not suitable for production!

Release highlights:
  • Numerous bug fixes, across the framework
  • Many missing features implemented, across the framework
  • Code coverage is up to 72%
  • CodeIgniter4 has been promoted to its own github organization. That is reflected in docs and comments.
  • We have integrated a git pre-commit hook, which will apply the CI4 code sniffer rules, and attempt to fix them.
    We have run all the source files through it, and any "funny" code formatting is temporary until the rules are updated.
  • We welcome Natan Felles, from Brazil, to the core CodeIgniter4 developer team. He has proven to be passionate, dedicated and thorough Smile
We have two distributions for the framework release, separate from the development codebase:
  • The released version of the framework has its own read only repository. This version does not include unit testing or the user guide, just the "meat". Spoiler: it can be downloaded or composer-installed.
  • We have an experimental app-starter, in its own read only repository. It contains only the application & public folders, Spoiler: it is meant to be composer-installed.
The user guide for the released version of CodeIgniter 4 is now published on github. Previous user guide links will lead to the "in development" version.

Check the changelog for details.

There are several possible ways to install the framework, explained on the installation page of the user guide,
or you can just download the runnable version as a zip or a tarball.


There are still some features incomplete or which need work, but we are making good progress.
Thank you to the community for stepping up to help make this the best PHP framework!

Do NOT post support questions or feature requests in response to this thread - those will be deleted. We are trying to make the best of the limited resources that we have!

Thank you, and ENJOY!

CSRF - Penetration Test

$
0
0
Interesting post on stack overflow. The OP is asking how to overcome the CSRF system flaw that testing has (supposedly) revealed.

I'm wondering if the assessment is valid. Thoughts?

Most feature rich plugin for creating REST APIs at this moment

$
0
0
Hi Community,

Please advise REST plugin for creating APIs that is latest and feature rich as of now.
For your information, APIs will be data intensive.

Please advise.

CIA3: How to turn the Debug Toolbar back on?

$
0
0
Hello All,

Thanks in advance for any help with this...

How do I turn on the wonderful Debug Toolbar in CodeIgniter 4 Alpha3?

Moo

HTML Escape on form helper

$
0
0
Hi all,
First time using a PHP framework and I chose to go with CI Heart . The documentation is awesome!
I'm a bit confused by the note on this page which says:

Quote:If you use any of the form helper functions listed on this page, the form values will be automatically escaped, so there is no need to call this function. Use it only if you are creating your own form elements.

What I thought it meant was if I'm using form helpers like form_input(), I don't have to manually do html_escape to the posted data from these fields. But I found out that this was not the case and the input wasn't html escaped.

Code:
<?=form_open('article/comment')?>
   <?=form_textarea('comment')?>
   <?=form_hidden('article',$article['id'])?>
   <?=form_submit('submit', 'Post comment.')?>
</form>
`echo $this->input->post('comment') ` in the controller returns unescaped html. It is also inserted into the database unescaped. I now use `html_escape($this->input->post())` instead of just `$this->input->post()` as a workaround. Is it the right way to do this? What does "form values will be automatically escaped" in the documentation actually mean?

Thanks in advance!

Interbase/Firebird Support in CI4

$
0
0
Hello CI,

Would you please give me some information about Interbase/Firebird support (driver) in CodeIgniter v4. I can't connect to localhost or remote Firebird 2.5 server which is not cased with CI3?

Scenario: I was made all modification on the database configuration file and when I call simple query I get "oops ci page" :-) I'll post here more information if you give me an idea how to represent this error.

Thanks for any info and assistance in the advance...

Sessions not deleting

$
0
0
My session files are not automatically being deleted. I have a client facing website that uses sessions with logins and a REST API that uses Codeigniter. The API doesn’t use any session data, but I think a session still gets started automatically. 

My session files are building up in: /var/cpanel/php/sessions/ea-php55

That directory gets up to 30 gigabytes in size. Why is it growing so large and why isn’t it cleaning on its own? 

These are my session settings:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = ‘mysession';
$config['sess_expiration'] = (60 * 60); 
$config['sess_save_path'] = FCPATH . "sessions";
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;

Any ideas? 

How do I instantiate a custom class based helper in a view

$
0
0
I have inherited a site based on the CI framework.

There is a custom helper 'imageresize_helper.php' built as a class with constructor rather than just functions:

Class ImageResize
{
   
   private $fileName;

   /**
   * @param string $fileName
   */
   function __construct($fileName)
   {
       $fileName = base_path($fileName);
   }


...

public function resizeImage($newWidth, $newHeight, $option = 'auto')
   {

}

The helper is referenced in autoload.php 
$autoload['helper'] = [
   'imageresize',
]   


How do I load & instantiate the helper class and call the resize function in a view?

Thanks

SeanR

How-to update codeigniter4 framework via composer?

$
0
0
Hi all,

I installed alpha2 via this command:

composer create-project codeigniter4/framework

(or I think I may have actually usedSmile

composer install codeigniter4/framework:dev-master

How do I update to alpha3 using composer? I ran:

composer update

in the framework directory and it only updated:

Package operations: 0 installs, 2 updates, 0 removals
  - Updating sebastian/environment (3.1.0 => 4.0.1): Downloading (100%)
  - Updating phpunit/phpunit (7.4.3 => 7.4.4): Downloading (100%)


I'm new to composer- could someone please tell me the command to update the entire framework from alpha2->alpha3?

Also, I'm concerned my application and public directories will get overridden. Is composer smart enough to leave those alone?

Thanks so much!

-Kyle

Illegal Offset in Route.php

$
0
0
I am currently trying to make things clean and neat and using the same endpoints for different things such as GET to /login - shows login page but POST to /login starts the login process. Going by the docs you can do this: 

PHP Code:
$route['login'] = 'auth/login';
$route['login']['POST'] = 'auth/loginProcess'

BUT this then throws the following error:

Quote:A PHP Error was encountered
Severity: Warning
Message: Illegal string offset 'POST'
Filename: config/routes.php
Line Number: 57

I tried putting ['GET'] against the first line but didn't seem to make any difference. Any help much appreciated.
Viewing all 14148 articles
Browse latest View live


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