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

Update sql query of multiple fields not working

$
0
0
Hi everybody, 
I'm trying to do an update query, it actually works updating one field but not with multiple fields.

Here's my code on the model:

PHP Code:
$array = array(
 
               'TIE_Nom'=>$TIE_Nom'TIE_Descripcion'=>$TIE_Descripcion'TIE_Gerent'=>$TIE_Gerent,'TIE_Telefon'=>$TIE_Telefon'TIE_Telefon2'=>$TIE_Telefon2'TIE_Telefon3'=>$TIE_Telefon3'TIE_Carrer'=>$TIE_Carrer'TIE_Carrer2'=>$TIE_Carrer2,'TIE_Carrer3'=>$TIE_Carrer3'TIE_InfoCarrer_amb_CP'=>$TIE_InfoCarrer_amb_CP'TIE_InfoOptometrista'=>$TIE_InfoOptometrista,'TIE_AudioProtesista'=>$TIE_AudioProtesista'TIE_ServeiOptom'=>$TIE_ServeiOptom,'TIE_ServeiAudio'=>$TIE_ServeiAudio'TIE_Email'=>$TIE_Email'TIE_BasePromocion'=>$TIE_BasePromocion'TIE_AliasBotiga'=>$TIE_AliasBotiga'TIE_Observacions'=>$TIE_Observacions,'TIE_Horari_Cas'=>$TIE_Horari_Cas'TIE_Horari_Cat'=>$TIE_Horari_Cat'TIE_Fichero_LOPD'=>$TIE_Fichero_LOPD'TIE_Razon_Fiscal'=>$TIE_Razon_Fiscal,'TIE_CodigoAxapta'=>$TIE_CodigoAxapta'TIE_Direccion_Fiscal'=>$TIE_Direccion_Fiscal'TIE_NIF'=>$TIE_NIF'TIE_NumeroFichero_LOPD'=>$TIE_NumeroFichero_LOPD,'TIE_CodigoINE'=>$TIE_CodigoINE'TIE_CodiPostal'=>$TIE_CodiPostal'TIE_Logo'=>$TIE_Logo'TIE_Facebook'=>$TIE_Facebook'TIE_Twitter'=>$TIE_Twitter,'TIE_Blog'=>$TIE_Blog'TIE_UrlFacebook'=>$TIE_UrlFacebook'TIE_UrlTwitter'=>$TIE_UrlTwitter,'TIE_UrlBlog'=>$TIE_UrlBlog'TIE_Web'=>$TIE_Web,'TIE_MyBusiness'=>$TIE_MyBusiness'TIE_Audio'=>$TIE_Audio'TIE_CuadrosdeMandoActivo'=>$TIE_CuadrosdeMandoActivo'TIE_Mostrar_Horari'=>$TIE_Mostrar_Horari,'TIE_Mostrar_Detalles_Cliente'=>$TIE_Mostrar_Detalles_Cliente 
            
);
$condicion "WEBLOGIN='$WEBLOGIN' AND TIE_Codigo=$TIE_Codigo";
 
           
$this
->db->trans_begin(); 

$this->db->where($condicion);

try{
 
    $this->db->update('TIENDA',$array);
}
catch (
Exception $e) {

 
    echo $e->getMessage();
}

if (
$this->db->trans_status() === FALSE){
 
                   
    $this
->db->trans_rollback();
}
else{
 
   $this->db->trans_commit();


As you can see it is a big query what I must do...
Can someone help me?  Blush

Error in the CodeIgniter 4 Tutorial

$
0
0
In the Static Page controller.

You have the route as this:
PHP Code:
$routes->get('(:any)''Pages::showme/$1'); 

But when you get to the News Section Create News item.

You have the routes like this:
PHP Code:
$routes->match(['get''post'], 'news/create''News::create');
$routes->get('news/(:segment)''News::view/$1');
$routes->get('news''News::index');
$routes->get('(:any)''Pages::view/$1'); 

See the Pages route, should be:
PHP Code:
$routes->get('(:any)''Pages::showme/$1'); 

Thanks.

PHPUnit - disable foreign keys check

$
0
0
Hello,

Where I can disable foreign keys check in testing environment? Which is best place?

Thanks for help.

Putting (hardcoded) ids in routes

$
0
0
In the tutorial, in the Routing section (https://codeigniter4.github.io/userguide...uting.html), the following code is used to map a route 'blog/joe' to a hardcoded id 34.


PHP Code:
$routes->add('blog/joe''Blogs::users/34'); 

I want to do something similiar, mapping page slugs to my Page controller with a certain id. I am using the following code to do this, where $page is the page variable.

PHP Code:
$routes->get$page->slug'Pages::id/' $page->id ); 

I can't get this to work. When I visit localhost:8080/my-page-slug I get a 404-error, saying Controller method is not found: id\123.

Am I doing something wrong with the mapping? Because if I visit localhost:8080/pages/id/123 it does work as expected.

I was wondering if it would be a problem if I add multiple slashes to the slug, for example, "/parent/child". However, I don't think that that is the problem since the error message seems to indicate that the mapping at least partially succeeded.

I hope someone can explain me what I am doing wrong.

Asset Loader Library

$
0
0
Hi all! I'm a long-time user with many live CI3 projects. Managing libraries across them got to be almost as much work as each project, so I developed five "zero conf" libraries to add core functions I needed which could be dropped in and used without setup. I never got around to publishing them, but as I rewrite them for CI4 I'll be making them available. The first library:

Tatter/Assets - "Zero conf" asset loader for CodeIgniter 4

Basic usage:

1. Run: `> composer require tatter/assets`
2. Put CSS & JS files in: public/assets
3. Add in head tag: `helper("tatter\assets"); css();`
4. Add to footer: `js();`


Since this is my first I am eager for feedback, suggestions, and contributions particularly on the "install/update - setup - use" pipeline which will be the same across all five libraries.
Thanks for reading!

Dynamic Routes

$
0
0
Hello all, I'm new to CI.
In my future project, we will have a menu structure like this:
Menu1
--Submenu1
--Submenu2
--[...]
Menu2
--Submenu3
--Submenu4
[...]

So, many menus, and each of them will have many submenus (many submenus will have a CRUD, or similar).
My problem is making the routes to all this pages, I would like to organize the Controllers inside folders (with the menu's name) and each submenu would be a Controller, like this:
/app/Controller/Menu1/Submenu1.php
/app/Controller/Menu1/Submenu2.php
/app/Controller/Menu2/Submenu1.php
etc...

But at the same time, I don't want to create one entry in the Routes.php file for each submenu, is there a way to create a route that simply takes the path URI and search in the folders for that exact values?

dynamic form_dropdown

$
0
0
Hello,

how to make a dynamic form_dropdown?
I have this in my view:
Code:
<tr>
<td align="right" scope="row">Project Name</td>
<td>
<?php

$project_id = set_value('project_id', @$user[0]->DFLT_PROJECT_ID);

echo form_dropdown('project_id"'.' class="form-control', $projectlist, $project_id);

            ?>
<span class="text-danger"><?php echo form_error('project_id'); ?></span>
</td>
</tr>
<tr>
<td align="right" scope="row">Stream Name</td>
<td>
<?php

$stream_id = set_value('stream_id', @$user[0]->DFLT_STREAM_ID);

echo form_dropdown('stream_id"'.' class="form-control', $streamlist, $stream_id);

            ?>
<span class="text-danger"><?php echo form_error('stream_id'); ?></span>
</td>
</tr>
 
I want the stream to be dependent on what the project_id will be. 

This is my controller 
Code:
    public function add_form_show($view) {
        $data['jira_hard_block'] = $this->settings_model->get_settings_by_type('JIRA_HARD_BLOCK');

        $session_user = get_cookie('auditme_cookie');
        $id = $this->user_model->get_id_by_user_name($session_user);
        $data['user'] = $this->user_model->get_user_by_id($id);
        $projectresult = $this->project_model->get_project_dropdown_list();
        $data['projectlist'] = $projectresult;
   $project_id = 1;
        $streamresult = $this->stream_model->get_stream_dropdown_list($project_id);
        $data['streamlist'] = $streamresult;

        $this->load->view($view, $data);
    }

And this is my model:

Code:
    function get_stream_dropdown_list($project_id = '') {
    if ($project_id <> ''){
      $this->db->where("proj_id",$project_id);
      }
$this->db->order_by('STREAM_CODE', 'ASC');
$query = $this->db->get('AUDIT_STREAM');


        $result = $query->result();
if ($query->num_rows()>0) {
$data[''] = '- Please Select -';
            foreach($query->result() as $row) {
                $data[$row->ID] = $row->STREAM_NAME;
            }
            return $data;
        }
        return $result;
    }

Help please.

Need help with CodeIgniter 3.1.4 Error need to fix with application with new server

$
0
0
CodeIgniter 3.1.4 Error need to fix with application with new server
this is the error : PHP Fatal error: session_start(): Failed to initialize storage module: user (path: sessions) in /home/usr/public_html/system/libraries/Session/Session.php on line 143 Using php 5.6 and try also in php 7 same issue.
The page showing blank page.

Update text from input to DB - not working

$
0
0
hello, i want update column "avatar" in DB table "account_data" but something is wrong ..... after submit button not update text from input to DB, thank you for help

https://pastebin.com/YE7f89x1

Difficulties accessing the base_url() function

$
0
0
Hello everyone,

It has been a few years since I have posted here.

I have run into an issue with CodeIgniter 3.1.10, I am trying to create a new site, ran into a bit of a hurdle when using other than the default 'welcome' controller, now this could be a rookie problem that I have forgotten about or it could be something with v 3.1.10
this is the error I am getting

Code:
development
An uncaught Exception was encountered
Type: Error

Message: Call to undefined function base_url()

Filename: C:\Apache24\htdocs\ci3blank\application\views\includes\header.php

Line Number: 17

Backtrace:

File: C:\Apache24\htdocs\ci3blank\application\views\includes\template.php
Line: 3
Function: view

File: C:\Apache24\htdocs\ci3blank\application\controllers\Site_controller.php
Line: 20
Function: view

File: C:\Apache24\htdocs\ci3blank\index.php
Line: 349
Function: require_once

What further code would you require from me

How can I get session at multiple controllers

$
0
0
Hi,
I set SESSION at Login.php controller, And I want get SESSION at other controllers,
But at other controllers, I get SESSION have `__ci_last_regenerate: 1552555932` only, No information I have stored in it.
What can I do something get the SESSION?
Thanks!

This is my Login.php controller

PHP Code:
class Account extends CI_Controller
 
{
 
 public function __construct()
 
 {
 
  parent::__construct();
 
  $this->load->model('Account_model');
 
  $this->load->library('session');
 
 }


 
 public function login()
 
 {
 
  $username $this->input->post('username');
 
  $password $this->input->post('password');

 
  // run login model,return array or FALSE
 
  $query $this->Account_model->login($username$password);

 
  if ($query) {
 
   // set SESSION
 
   // $query is array, like this :{'username'=>"bob",'level'=>2}
 
   $this->session->set_userdata($query);
 
   //do something...
 
  }
 
 }


And this controllers, I want use SESSION, but faile

PHP Code:
class Number_record extends CI_Controller
{
 public function 
__construct()
 {
 
 parent::__construct();
 
 $this->load->model('Number_record_model''NRM');
 
 $this->load->library('session');
 }

 public function 
add_num()
 {
 
 // I want get SESSION at this
 
 // But only get this :__ci_last_regenerate: 1552555932
 
 $_SESSION;
 
 $this->session->userdata()
 }

Display a view page in the div element

$
0
0
I am working on some project using codeIgniter. I got stuck with a small UI part. I was asked to display page in the particular div element instead of displaying it in the new tab.

Can anyone provide me the solution for that ?

Class DotEnv and Autoload

$
0
0
Hello everyone,

I started using CodeIgniter lately in version 3. I am self taught and had never used a framework before. By cons I tested 7 different and Codeigniter in his V3 is the one that was closest to my style of coding. The version 4 is a total redesign, I fully understand that we must be in the style of the day but I have a little trouble anyway ... In short.

I want to make a .env file load relative to where the application is located: production, testing, development. I have tried multiple way to load a class in app/config which normally is in the logic that must load the files in the folder automatically. Something that does not happen while I respect the namespace. There, I did as in the documentation with a class implements so to make a personal class ... It does not load. So here is the test code:
Code:
<?php namespace Config;

use CodeIgniter\Config\DotEnv;

class Env implements DotEnv
{
   /**
     * The directory where the .env file can be located.
     *
     * @var string
     */
    protected $path;

    //--------------------------------------------------------------------

    /**
     * Builds the path to our file.
     *
     * @param string $path
     * @param string $file
     */
    public function __construct(string $path, string $file = '.env_development')
    {
        $this->path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
    }

    etc...
}

Here I want the file that loads to be the one for the development. I made the tests from the original file with if conditions, it works great. By cons when I make sure to make my own class in the app/Config folder, nothing happens because no automatic loading. I even try to make mistakes and nothing happens (logical because it automatically goes into production). Can you enlighten me on this point, especially on the operation of autoload, because even by doing individually with $classmap, nothing happens.

Looking forward to reading you,
Regards,

PS: Sorry for my english

unable to open modal pop up window

$
0
0
i want to open modal window using php codeigniter. but the error occured.
Code:
<td>

<button class="btn btn-warning" onclick="edit_book(<?php echo $book['appno'];?>)"><i class="glyphicon glyphicon-pencil"></i></button> </td>
Uncaught ReferenceError: app005 is not defined

   at HTMLButtonElement.onclick (v_dashboard:190

How to insert a verifed logo and some details to the uploaded document


Problem with pagination that have crud

$
0
0
I follow a tutorial on making a blog application using Codeigniter 3x

here is the link : https://www.youtube.com/watch?v=WoQTjJepDWM

at the end of the tutorial, he shows how to make pagination but it didn't work for me, my other controller work because it didn't have crud, on this controller page that I'm working on right have a crud and it didn't let the pagination work, the limit work, but pagination link didn't show.
I'm using a blog design for my news page.

Here is my controller : 
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

        class News extends CI_Controller {
        function __construct() {
             parent::__construct();
             $this->load->model('news_model');
             $this->load->helper('date');
                 //load pagination library
           $this->load->library('pagination');
        }

            public function index($offset = 0){

        //Pagination Config
        $config['base_url'] =  base_url() . 'news/index/';
        $config['total_row'] =$this->db->count_all('omg_new');
        $config['per_page'] = 2;
        $config['uri_segment'] = 3;
        $config['attributes'] = array('class' => 'pagination-link');
   
        // Init Pagination
        $this->pagination->initialize($config);

        $data['title'] = 'Latest News';

        $data['news'] = $this->news_model->get_posts(FALSE, $config['per_page'], $offset);


    $this->load->view('templates/header');
    $this->load->view('news/index', $data);
    $this->load->view('templates/footer');
    }
    
    public function view($slug = NULL){

        $data['post'] = $this->news_model->get_posts($slug);

            if(empty($data['post'])){
                show_404();
            }

            $data['title'] = $data['post']['title'];


        $this->load->view('templates/header', $data);
        $this->load->view('news/view', $data);
        $this->load->view('templates/footer');


    }

    public function create(){
        $data['title'] = $data['post']['title'];

    $this->load->view('templates/header', $data);
    $this->load->view('news/index', $data);
    $this->load->view('templates/footer');
    }
    

    
}

My model : 

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News_model extends CI_Model {

    public function __construct()
    {

  $this->load->database();
 
    }

    public function get_posts($slug = FALSE, $limit = FALSE, $offset = FALSE){

    if($limit){
        $this->db->limit($limit, $offset);
    }    

        if($slug === FALSE){
            $this->db->order_by('omg_new.new_id', 'DESC');
            $this->db->join('omg_cat_new','omg_cat_new.cat_new_id = omg_new.cat_new_id');
            $query = $this->db->get('omg_new');
        return $query->result_array();
   }
        
    $query = $this->db->get_where('omg_new', array('slug' => $slug));
            return $query->row_array();

    
    }

}

My index page for news : 

Code:
     <div class="col-md-10 offset-md-1 col-lg-9 offset-lg-0">
       
 
     <div class="section-title">
         <h2><?= $title ?></h2>
         <p></p>
       </div>

 <?php foreach ($news as $post) : ?>

<article>

<div class="col-md-6">
   
       <img src="<?php echo site_url(); ?>assets/upload/<?php echo $post['fea_img']; ?>" alt="">
     
   </div>

<h3><?php echo $post['title']; ?></h3>
<ul class="list-inline">
   <li class="list-inline-item">Categories : <strong><?php echo $post['name']; ?></strong></li>
   <li class="list-inline-item"></li>
 </ul>

<p class=""><?php echo word_limiter($post['content'],40); ?></p>

<a href="<?php echo site_url('/news/'.$post['slug']); ?>" class="btn btn-transparent">Read More</a>

</article>
 <?php endforeach; ?>

 <!-- Pagination -->
 <div class="pagination-links">
       <nav aria-label="Page navigation example">
         <ul class="pagination">
         
          <?php echo $this->pagination->create_links();?>

         </ul>
       </nav>
       </div>
       
</div>

and my view page after clicking read more : 

Code:
  <div class="row">
     <div class="col-md-10 offset-md-1 col-lg-9 offset-lg-0">
       
 
   <article>
       <div class="col-md-6">
      <img src="<?php echo site_url(); ?>assets/upload/<?php echo $post['fea_img']; ?>" alt="">
   </div>
<h3><?php echo $post['title']; ?></h3>
<ul class="list-inline">
   <li class="list-inline-item"></li>
   <li class="list-inline-item"></li>
 </ul>
<p class=""><?php echo $post['content']; ?></p>


</article>
</div>

Can someone help me with this,Sad because I have followed the tutorial correctly but didn't know what was wrong?

$route array CI3

$
0
0
Hi,

Is there a standard way to access the $route array? similar to accessing config items?

Controller named Icons not working

$
0
0
When I create a controller named Icons, it is not working. When I renamed the controller Icon, it works properly. Is Icons a reserved keyword ?

Codeigniter best script to start paid or not

$
0
0
Hi , I have developed a CI app for about 3 years ago and now I want a new start for it . I'm looking for a paid or not script that will help me start with the best standards. Most important things for me is secure login , ajax , user roles , jquery/bootstrap . It would be great if this app included ajax datatables , form builder. Basically I want and admin theme , but coded with CI . Looked everywhere , only found obsolete scripts . The best one I found and have worked with is SMA ( Stock manager advance) from envato and there is potential there but the code is kind of a mess .
My current app looks great , but in terms of scale is not great .
TLDR: I want to start a CI app from a script with the best practices .

Mobile forum?

$
0
0
This forum is a pain to navigate on mobile. I understand it was written by one of the admins? Any chance to get an update for mobile-friendly layout?
Viewing all 14057 articles
Browse latest View live


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