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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 12,320
» Latest member: nandhinichandran
» Forum threads: 68,560
» Forum posts: 427,553

Full Statistics

Latest Threads
CI 3.1 for Website Buildi...
Forum: Choosing CodeIgniter
4 hours ago
» Replies: 6   » Views: 3,632
Introducing TastyIgniter ...
Forum: Spotlight
5 hours ago
» Replies: 20   » Views: 22,265
Hours spent on computer?
Forum: Lounge
6 hours ago
» Replies: 32   » Views: 12,553
Do you have a hobby?
Forum: Lounge
6 hours ago
» Replies: 26   » Views: 9,523
automatic logout after in...
Forum: General Help
9 hours ago
» Replies: 0   » Views: 36
Shopping cart library not...
Forum: CodeIgniter 2.x
9 hours ago
» Replies: 1   » Views: 27
Which web hosting to use
Forum: Lounge
Yesterday, 02:58 PM
» Replies: 29   » Views: 14,632
How many pets do you own?
Forum: Lounge
Yesterday, 02:51 PM
» Replies: 10   » Views: 4,534
Which browser do you guys...
Forum: Lounge
Yesterday, 02:48 PM
» Replies: 44   » Views: 12,090
CodeIgniter 4.0.0-alpha.1...
Forum: News & Discussion
Yesterday, 01:49 PM
» Replies: 29   » Views: 17,852

 
  pagination incorrect in oci8 driver oracle
Posted by: Miko - 10-15-2018, 08:15 AM - Forum: Libraries & Helpers - No Replies

Hello, I use codeigniter since few week and i just see a mistake... with oracle < 12.1 the pagination is incorrect :

In system/database/driver/oci8/oci8_driver.php you have to modify function _limit:


/**
     * LIMIT
     *
     * Generates a platform-specific LIMIT clause
     *
     * @param   string  $sql    SQL Query
     * @return  string
     */
    protected function _limit($sql)
    {
        if (version_compare($this->version(), '12.1', '>='))
        {
            // OFFSET-FETCH can be used only with the ORDER BY clause
            empty($this->qb_orderby) && $sql .= ' ORDER BY 1';

            return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY';
        }

        $this->limit_used = TRUE;
        return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->qb_offset + $this->qb_limit + 1).')'
            .($this->qb_offset ? ' WHERE rnum >= '.($this->qb_offset + 1) : '');

    }




Calcul of limit is not exact in this case.


With this code it's ok  :




/**
     * LIMIT
     *
     * Generates a platform-specific LIMIT clause
     *
     * @param   string  $sql    SQL Query
     * @return  string
     */
    protected function _limit($sql)
    {
        if (version_compare($this->version(), '12.1', '>='))
        {
            // OFFSET-FETCH can be used only with the ORDER BY clause
            empty($this->qb_orderby) && $sql .= ' ORDER BY 1';

            return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY';
        }

        if($this->qb_offset=="") $this->qb_offset=1;
        $this->limit_used = TRUE;
        return 'SELECT * FROM (SELECT /*+ FIRST_ROWS(n) */ inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.(($this->qb_offset * $this->qb_limit)+ 1).')'
            .($this->qb_offset ? ' WHERE rnum >= '.(($this->qb_offset - 1)*$this->qb_limit+1) : '');
    }



Have fun & code Wink
Nico (Miko)


  Is there away I can order table data ?
Posted by: cyjuice - 10-15-2018, 01:33 AM - Forum: General Help - Replies (2)

[Image: hdVdw.png]

My table looks like this , and I'm trying to allow user to change data order asc/desc by clicking the button at thead. I'm not sure how to do it , any idea ?


  Best course move CI knowledge from Intermediate to Expert?
Posted by: zurtri - 10-14-2018, 04:10 PM - Forum: General Help - Replies (4)

I have been using CI for a few years now and have several products in production using it.

I consider myself to have intermediate knowledge of CI.

If there a course out there that could take me from intermediate to expert level of knowledge?

Or would it be best to wait till CI4 before doing said course?

Thanks in Advance!


  Codeigniter blog application: replace post id with slug in the singe post url only
Posted by: Ajax30 - 10-14-2018, 11:30 AM - Forum: CodeIgniter 3.x - No Replies

I am working on a basic blog application in Codeigniter 3.1.8 and Bootstrap 4.

I have been working for some time on this application and consequently, it has a lot of features. Most of these rely on the ids of posts, pages, etc.
For SEO purposes, I would like to use friendly URLs, instead of ids to display the individual posts, so I have added a slug 
column to the posts table.


[Image: BtkBH.png]

The slugs are made from post titles, with this chunks of code in the Posts_model model and the Posts controller, respectively.
From the model:


Code:
public function slug_count($slug){
   $this->db->select('count(*) as slugcount');
   $this->db->from('posts');
   $this->db->where('slug', $slug);
   $query = $this->db->get();
   return $query->row(0)->slugcount;
}

public function create_post($post_image, $slug) {
   $data = [
       'title' => $this->input->post('title'),
       'slug' => $slug,
       'description' => $this->input->post('desc'),
       'content' => $this->input->post('body'),
       'post_image' => $post_image,
       'author_id' => $this->session->userdata('user_id'),
       'cat_id' => $this->input->post('category'),
       'created_at' => date('Y-m-d H:i:s')
   ];
   return $this->db->insert('posts', $data);
}

From the controller:

Code:
// Create slug (from title)
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$slugcount = $this->Posts_model->slug_count($slug);
if ($slugcount > 0) {
   $slug = $slug."-".$slugcount;
}

To achieve my SEO goal, I have considered and tried out the approach in this tutorial but since there are numerous functionalities needing ids (deleting posts via AJAX, for example) and other that do not require slugs (editing posts) I am unable (and unwilling) to substantially modify the post viewing method in the controller,

Code:
public function post($id) {
   $data = $this->Static_model->get_static_data();
   $data['pages'] = $this->Pages_model->get_pages();
   $data['categories'] = $this->Categories_model->get_categories();
   $data['posts'] = $this->Posts_model->sidebar_posts($limit=5, $offset=5);
   $data['post'] = $this->Posts_model->get_post($id);

   if ($data['categories']) {
       foreach ($data['categories'] as &$category) {
           $category->posts_count = $this->Posts_model->count_posts_in_category($category->id);
       }
   }

   if (!empty($data['post'])) {
       // Overwrite the default tagline with the post title
       $data['tagline'] = $data['post']->title;

       // Get post comments
       $post_id = $data['post']->id;
       $data['comments'] = $this->Comments_model->get_comments($post_id);

       $this->load->view('partials/header', $data);
       $this->load->view('post');
   } else {
       $data['tagline'] = "Page not found";
       $this->load->view('partials/header', $data);
       $this->load->view('404');
   }
   $this->load->view('partials/footer');
}

and the corresponding code in the model:

Code:
public function get_post($id) {
   $query = $this->db->get_where('posts', array('id' => $id));
   if ($query->num_rows() > 0) {
       $data = $query->row();
       // run separate query for author name
       $author_query = $this->db->get_where('authors', array('id' => $data->author_id));
       if ($author_query->num_rows() == 1) {
           $author = $author_query->row();
           $data->first_name = $author->first_name;
           $data->last_name = $author->last_name;            
       } else {
           $data->first_name = 'Unknown';
           $data->last_name = '';
       }
       return $data;
   }
}

What would be a simple, less "intrusive" approach to replace post id with slug in the singe post view only?


Video I don't find the read_file function in the file system helper
Posted by: titounnes - 10-14-2018, 10:16 AM - Forum: CodeIgniter 4 Feature Requests - Replies (2)

Hi, J.P.
Why CI4 doesn't provide a funtion to read files in file_system_helper?


  Non PHP Config Files in CodeIgniter 3
Posted by: ItsSeaJay - 10-14-2018, 04:12 AM - Forum: General Help - Replies (1)

Is there a clean way of replacing the PHP config files in CodeIgniter 3 with a different format like JSON or TOML without having to type in the location of the value for each variable in the PHP file? Is this even a good idea?


  Problem css on page
Posted by: h3yb0y - 10-13-2018, 01:48 PM - Forum: General Help - Replies (4)

Hello, sorry for disturb, i have a problem in my website, not load correctly css of one page in one linux hosting.
In develop hosting work correctly (xampp), in other webhosting with plesk work correctly
 
[Image: o781nd.png]

In hosting production not work correctly:
[Image: 2qiskm1.png]

In error log i see:
404 Page Not Found: Css/jquery.dataTables.min.css
404 Page Not Found: Css/Redirecting.css

The code is:

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="Funny Dog" content="Aggiungi Veterinario">
<title>Aggiungi Veterinario</title>
<style type="text/css">      .table-condensed thead tr th{color: #faa200 !important;}</style>
<?php include('top.php') ?>
   <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/css/bootstrap-select.min.css" />
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/jquery.dataTables.min.css">


</head>
<body>
<div class="se-pre-con loading_div"></div>
<div class="wrapper">

<!-- header start -->

<?php include('header.php') ?>
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/Redirecting.css">

<!-- header end here -->



<section id="main" class="container-fluid">
<div class="row">

<section id="content-wrapper" class="form-elements">

<div class="site-content-title">
<h2 class="float-xs-left content-title-main"><?php if(!empty($veterinary_id)){ echo 'Edit';}else{ echo 'Add';} ?> Veterinary</h2>

<ol class="breadcrumb float-xs-right">
<li class="breadcrumb-item">
<span class="fs1" aria-hidden="true" data-icon=""></span>
<a href="index.php">Home</a>
</li>
<li class="breadcrumb-item active"><a href="<?php echo base_url(); ?>veterinary_list">Veterinary List</a></li>
<li class="breadcrumb-item active"><?php if(!empty($veterinary_id)){ echo 'Edit';}else{ echo 'Add';} ?> Veterinary</li>

</ol>

</div>


<div class="contain-inner dashboard_v4-page">

<!-- middle section -->
<div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 veter-cc">

<!-- row -->
<div class="row">

<div class="content" style="padding-bottom: 100px;">
<!--==========================had-cus-sty========================-->
<div>
<div class="col-md-12 col-sm-12 col-xs-12 col-lg-6">
<h4 class="page-content-title"><?php if(!empty($veterinary_id)){ echo 'EDIT';}else{ echo 'ADD';} ?> VETERINARY</h4>
</div>



<hr class="hr-one">

<div class="clerfix"></div>
</div>

<!--=================================table data==============================-->
<div class="ribbon-box left-ribbon-box col-md-12 col-sm-12 col-lg-12 col-xs-12">
   <div class="border-ribbon left-side">
       <div class="ribbon-position left-border-ribbon left-ribbon-position ">
       </div>
      Veterinary Form
   </div>
<form id="AddVeterinaryList">

<input type="hidden" name="veterinary_id" value="<?php if(!empty($veterinary_id)){ echo $veterinary_id;} ?>">

<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                       <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                           <label class="mdtory-icn">Veterinay Name </label>
                                       </div>
                                       <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12 res-pad">
                                           <div class="form-group">
                                               <input class="form-control" type="text" placeholder="Veterinay Name" name="veterinary_name" id="veterinary_name" value="<?php if(!empty($single_veterinary->veterinary_name)){ echo $single_veterinary->veterinary_name;} ?>">
                                           </div>
                                       </div>
                                   </div>


                                 </div>


                           

                                 <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                       <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                           <label >Address </label>
                                       </div>
                                       <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12 res-pad">
                                           <div class="form-group"><textarea class="form-control" placeholder="Complete Address" rows="3" name="veterinary_address"> <?php if(!empty($single_veterinary->veterinary_address)){ echo $single_veterinary->veterinary_address;} ?></textarea>
                                           </div>
                                       </div>
                                   </div>

                                   
                                 </div>

                                 <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                     <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                       <label class="rsp-flot">Province</label>
                                     </div>
                                     <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12">

                                       <div class="form-group">
                                         <select class="form-control selectpicker form-control provincia_sel1" data-show-subtext="true" data-live-search="true" placeholder="Province" name="veterinary_provincia" id="veterinary_provincia" >
                                             <option value="" selected=""> Select Provincia </option>
                                             <?php if(!empty($provincia))
                                             {
                                                 foreach ($provincia as $p_value) {
                                             ?>
                                               <option <?php echo ($veterinary_id!="" && $single_veterinary->veterinary_provincia == $p_value['p_id'] ? 'selected="selected"' : ""); ?>data-title="<?php echo $p_value['provincia'] ?>" value="<?php echo $p_value['p_id'] ?>"> <?php echo $p_value['provincia'] ?> </option>
                                             <?php
                                             }
                                             } ?>
                                         </select>
                                       </div>
                                     </div>
                                   </div>
                                 </div>
                                 <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                     <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                       <label class="rsp-flot">Città</label>
                                     </div>
                                     <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12">
                                       <div class="form-group">                                          
                                          <div class="form-group">
                                               <select class="form-control city_sel" data-show-subtext="true" data-live-search="true" placeholder="City" name="veterinary_city" id="veterinary_city">
                                                    <option value="<?php if(isset($result->cityname)) { echo "selected"; } ?>" selected=""> Select City </option>
                                                   <?php
                                                    $cities = $this->db->where('c_provincia',$single_veterinary->veterinary_provincia)->get("cities")->result_array();
                                                   if(!empty($cities)){ ?>
                                                   <?php foreach($cities as $itemCity){ ?>
                                                       <option <?php echo (!empty($itemCity) && $single_veterinary->veterinary_city == $itemCity['c_id'] ? 'selected="selected"' : ""); ?>data-title="<?php echo $itemCity['cityname'] ?>" value="<?php echo $itemCity['c_id'] ?>"> <?php echo $itemCity['cityname'] ?> </option>
                                                   <?php
                                                   }
                                                     } ?>
                                               </select>
                                           </div>
                                       </div>
                                     </div>
                                   </div>
                                 </div>

                                 <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                     <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                       <label class="rsp-flot">Codice Postale</label>
                                     </div>
                                     <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12">
                                      <div class="form-group">
                                               <select class="form-control postal_sel" data-show-subtext="true" data-live-search="true" placeholder="Postal Code" name="veterinary_postal_code" id="customer_postal_code" >
                                                   <option value="" selected=""> Select Postal </option>
                                               </select>
                                           </div>
                                     </div>
                                   </div>
                                 </div>
                                     

                                      <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                       <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                           <label >Telephone </label>
                                       </div>
                                       <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12 res-pad">
                                           <div class="form-group">
                                               <input class="form-control numeric" type="text" placeholder="Telephone" name="veterinary_telephone" value="<?php if(!empty($single_veterinary->veterinary_telephone)){ echo $single_veterinary->veterinary_telephone;} ?>">
                                           </div>
                                       </div>
                                   </div>

                                   
                                 </div>


                                   <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                       <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                           <label >Emergency Telephone   </label>
                                       </div>
                                       <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12 res-pad">
                                           <div class="form-group">
                                               <input class="form-control numeric" type="text" placeholder="Emergency Telephone " name="veterinary_emergency_telephone" value="<?php if(!empty($single_veterinary->veterinary_emergency_telephone)){ echo $single_veterinary->veterinary_emergency_telephone;} ?>">
                                           </div>
                                       </div>
                                   </div>

                                   
                                 </div>
 <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                       <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                           <label >Email  </label>
                                       </div>
                                       <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12 res-pad">
                                           <div class="form-group">
                                               <input class="form-control " type="email" placeholder="Enter Email" name="veterinary_email" value="<?php if(!empty($single_veterinary->veterinary_email)){ echo $single_veterinary->veterinary_email;} ?>">
                                           </div>
                                       </div>
                                   </div>

                                   
                                 </div>

<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12 res-pad">
                                   <div class="element-form">
                                       <div class="col-xl-2 col-lg-3 col-md-3 col-sm-12 col-xs-12 text-xs-right res-pad">
                                           <label >Note  </label>
                                       </div>
                                       <div class="col-xl-9 col-lg-9 col-md-9 col-sm-12 col-xs-12 res-pad">
                                           <div class="form-group"><textarea class="form-control" rows="3" name="veterinary_note"> <?php if(!empty($single_veterinary->veterinary_note)){ echo $single_veterinary->veterinary_note;} ?></textarea>
                                           </div>
                                       </div>
                                   </div>

                                   
                                 </div>





<div class="col-md-offset-3 col-lg-offset-3  col-lg-9 col-md-9 col-sm-12 col-xs-12">
                                 

                                  <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12 ">
                                  <input type="submit" value="Submit" class="btn btn-primary pull-right  hvr-trim sub-btn-sty">
                                 <!--  <button class="btn btn-primary pull-right  hvr-trim sub-btn-sty"> Submit</button> -->
                                   </div>
                                 </div>

                                 </form>
<div class="clerfix"></div>
</div>





<!--===========================================================-->
</div>


</div>




<!-- row end -->
</div>

    

</div>

<!-- middle section end  -->
</div>

</section>

<!-- </div>
</section>
 -->
<!-- footer section start  -->
<?php include('footer.php') ?>


</div>
<script type="text/javascript">
 $(document).on('change','.provincia_sel1',function(){

   var p_id=$('.provincia_sel1 option:selected').val();
   if(p_id!='')
   {
     $.ajax({
     url:'<?php echo base_url(); ?>Setting/get_selected_city',
     type:'post',
     data:{p_id:p_id},
     success:function(data)
     {
       if(data!='')
       {
         $(".city_sel").html('<option value="">Select City</option>'+data);
       }
     }
   })
   }
   
 });

 $(document).on('change','.city_sel',function(){
   var c_id=$('.city_sel option:selected').val();
   if(c_id!='')
   {
     $.ajax({
     url:'<?php echo base_url(); ?>Setting/get_selected_postal',
     type:'post',
     data:{c_id:c_id},
     success:function(data)
     {
       if(data!='')
       {
         $(".postal_sel").html('<option value="">Select Postal</option>'+data);
       }
     }
   })
   }
   
 });
</script>


</body>






</html>

Thanks for you patience and attention.


  Problem in load css
Posted by: omid_student - 10-13-2018, 07:20 AM - Forum: General Help - Replies (13)

Hi
When i load page,sometime website cannot load completely (css and other)
After reload page,it is OK
Why?
I attach picture here
Correct page is :
   

And when my page is not complete loading
   


  array in .env file
Posted by: obozdag - 10-13-2018, 02:04 AM - Forum: CodeIgniter 4 Support - Replies (4)

In App.php there is an array variable:
    public $toolbarCollectors = [
        'CodeIgniter\Debug\Toolbar\Collectors\Timers',
        'CodeIgniter\Debug\Toolbar\Collectors\Database',
        'CodeIgniter\Debug\Toolbar\Collectors\Logs',
        'CodeIgniter\Debug\Toolbar\Collectors\Views',
//        'CodeIgniter\Debug\Toolbar\Collectors\Cache',
        'CodeIgniter\Debug\Toolbar\Collectors\Files',
        'CodeIgniter\Debug\Toolbar\Collectors\Routes',
        'CodeIgniter\Debug\Toolbar\Collectors\Events',
    ];

Is it possible to define an array variable in .env file?
For example:
app.css_files = [
     'bootstrap.css',
     'fontawesome.css',
     'stylesheet.css'
]
or
app.css_files = ['bootstrap.css', 'fontawesome.css', 'stylesheet.css']


  how to add 2 row data in mpdf
Posted by: kvanaraj - 10-12-2018, 11:29 PM - Forum: Lounge - Replies (4)

I want to add two rowdata in one value using mpdf 

Code:
<td align="center"><h3>'. $row_dummy['remun'].'</h3></td>
<td align="center"><h3>'. $row_dummy['lum'].'</h3></td>
i try 1
Code:
<td align="center"><h3>'. <?php {$row_dummy['remun']+$row_dummy['lum']} ?> .' </h3></td>


no display



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