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

How to get all posts from a facebook page and show using codeigniter

$
0
0
Dear All,

I am using a codeigniter project. I need to show facebook post from a facebook page in a website. How can I do this using codeigniter. 
Please give your valuable solutions. Thanks in advance.

Hamid Khan

Problem when updating the user data form

$
0
0
Hello, I´m new for here. I have a problem when updating the user data form, because when the user wants update his data in the form, input email show the error: "Email is already in use", It ´s logic because he hasn´t changed his email in the form and there is a validation rule "is_unique" for the email. Is there any way that this validation rule, Codeigniter ignore it in the user data form?

This is the file with the validation rules of that update form:

function getEditRules() {
    return array(
        
        array(
            'field' => 'email', 
            'label' => 'email',
            'rules' => 'required|valid_email|max_length[100]|is_unique[user.email]|trim',
            'errors' => array('required' => 'Introduce a %s', 'max_length' => 'The %s can´t exceed 100 characters', 'valid_email' => 'The %s is not valid', 'is_unique' => 'The %s is already in use')
        ),
        array(
            'field' => 'password',
            'label' => 'password',
            'rules' => 'required|min_length[6]|matches[password_confirm]|trim',
            'errors' => array(
                'required' => 'Introduce a %s.', 'min_length' => 'The %s must have at least 6 characters', 'matches'=>'Passwords don´t match
            ),
        ),
        array(
            'field' => 'password_confirm',
            'label' => 'password',
            'rules' => 'required|min_length[6]|trim',
            'errors' => array(
                'required' => 'Introduce a %s.', 'min_length' => 'The %s must have at least 6 characters'
            )
        )
    );
}

Thanks you very much

codeigniter session duplicate with cloudflare

$
0
0
Hi, I'm using Ion Auth social
https://github.com/ghosthouse/CodeIgnite...uth-Social

and throughout my web check if the user has a session started or not.
PHP Code:
if ($ this-> ion_auth-> logged_in ()) {

For this reason in /application/config/autoload.php charge

PHP Code:
autoload ['libraries'] = array ('ion_auth'); 

in my localhost everything is perfect, but in my website protected with cloudflare, create multiple sessions just with this:

PHP Code:
__ci_last_regenerate i1544893031

create more than 50 sessions per second only with this info which overloads my sql, I think it is a problem of CodeIgniter sessions with cloudflare.

So I'm wondering if you can share an option / solution, so that only one codeigniter session is created when the user logs in Ion Auth.
Thank you.

CodeIgniter 4.0.0 Alpha.4 released

$
0
0
CodeIgniter-4.0.0-alpha.4 launches today [Image: smile.gif]

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

Release highlights:
  • Refactor for consistency: folder application renamed to app; constant BASEPATH renamed to SYSTEMPATH
  • Missing features implemented, across the framework
  • Code coverage is up to 73%
  • Debug toolbar gets its own config, history collector

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.
    Caution: we are still working on updating the system paths automatically after installation!


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!

Cannot connect to reCAPTCHA to get facebook access toke

$
0
0
Dear All, 

To get facebook access token I have logged in to developers.facebook.com site. But cannot connect to reCAPTCHA to pass security check.
Would you please give me a proper solution? Attached here the screen shot.

Thanks
Hamid

.jpg   alert_fb.jpg (Size: 29.11 KB / Downloads: 2)

Undefined property

$
0
0
I think the program is correct, but it appears that it is an error. Please someone help me.

A PHP Error was encountered
Severity: Notice
Message: Undefined property: mysqli::$ProductID
Filename: controllers/ProductsUI.php


CI_Model:
PHP Code:
function get_product(){
 
      $this->load->database();
 
      return $this->db->get('product');
 
  

CI_Controller:
PHP Code:
$str '';
 
       $this->load->model('Product');
 
       foreach($this->Product->get_product() as $row){
 
           $str += 'tr role="row">
            <td>'
.$row->ProductID.'</td>
            <td>'
.$row->Product_Name.'</td>
            <td>'
.$row->Cost.'</td>
            <td><button>แก้ไข</button></td>
            <td><button>ลบ</button></td>
            </tr>'
;
 
       

Message: Undefined variable: _forename but its there

$
0
0
Hey, I am having a problem with a variable inside a class not being seen even though its there. Please help!

User Controller

public function create() {

        $params = array('x', 'xxx', 'xxxxx', 'xxxxxx', 'x', 'xx', 'xxxx');
        $this->load->library('User', $params);
    }


User Library


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class User {
   public $_forename          = "";
   public $_surname           = "";
   public $_dob               = "";
   public $_address           = "";
   public $_telephone         = "";
   public $_email             = "";
   public $_password          = "";
   
   public function __construct($params) {

       $this->setForename($params[0]);
       $this->setSurname($params[1]);
       $this->setDOB($params[2]);
       $this->setAddress($params[3]);
       $this->setTelephone($params[4]);
       $this->setEmail($params[5]);
       $this->setPassword($params[6]);

   }

   public function getForename()   { return $this->$_forename; }
   public function getSurname()    { return $this->$_surname; }
   public function getDOB()        { return $this->$_dob; }
   public function getAddress()    { return $this->$_address; }
   public function getTelephone()  { return $this->$_telephone; }
   public function getEmail()      { return $this->$_email; }
   public function getPassword()   { return $this->$_password; }

   public function setForename($value)       { $this->$_forename = $value; }
   public function setSurname($value)        { $this->$_surname = $value; }
   public function setDOB($value)            { $this->$_dob = $value; }
   public function setAddress($value)        { $this->$_address = $value; }
   public function setTelephone($value)      { $this->$_telephone = $value; }
   public function setEmail($value)          { $this->$_email = $value; }
   public function setPassword($value)       { $this->$_password = $value; }

   public function print_m() {
       echo getForename();
       echo getSurname();
       echo getDOB();
       echo getAddress();
       echo getTelephone();
       echo getEmail();
       echo getPassword();
   }

   public function hashPassword($password) {

       return password_hash($password, PASSWORD_BCRYPT);
   }

   public function selectAll()             { return 0; }
   public function selectSingle($value)    { return 0; }
   public function orderBy($value)         { return 0; }
   public function insertInto($value)      { return 0; }
   public function update($value)          { return 0; }
   public function delete($value)          { return 0; }
}

Mpdf report second page not display table

$
0
0
I am using mpdf class to generate report. In this report contains multiple header shows all pages. but it shows only in first page.
Code:
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
    font-size: 10pt;
}
p {    margin: 0pt; }
table.items {
    border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
    border-left: 0.1mm solid #000000;
    border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
    text-align: center;
    border: 0.1mm solid #000000;
    font-variant: small-caps;
}
.items td.blanktotal {
    background-color: #EEEEEE;
    border: 0.1mm solid #000000;
    background-color: #FFFFFF;
    border: 0mm none #000000;
    border-top: 0.1mm solid #000000;
    border-right: 0.1mm solid #000000;
}
.items td.totals {
    text-align: right;
    border: 0.1mm solid #000000;
}
.items td.cost {
    text-align: "." center;
}
</style>
</head>
<body>



<htmlpageheader name="myheader">
<table width="100%">
<tr>
   <td rowspan="3"><img src="assets/images/logo.gif" width="80px" /></td>
   <td align="center" style="font-size:20px"><strong>Header1 </strong></td>
 </tr>
 <tr>
   <td align="center" style="font-size:16px"><strong>Header2  </strong> </td>
 </tr>
 <tr>
   <td align="center" style="font-size:14px"><strong>Header3 </strong></td>
 </tr>
 </table>
</htmlpageheader>

<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>

<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />


<div style="text-align: right">Date: 13th November 2008</div>



<br />

<!--  This header should be displayed all pages ----->

<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8" >
<thead>
<tr>
<td width="15%">Ref. No.</td>
<td width="10%">Quantity</td>
<td width="45%">Description</td>
<td width="15%">Unit Price</td>
<td width="15%">Amount</td>
</tr>
</thead>
<tbody>
<tr>
<td align="center">MF1234567</td>
<td align="center">1500</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
</tbody>
</table>


<br/>
<!--  This header should be displayed all pages ----->
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="15%">Ref. No.</td>
<td width="10%">Quantity</td>
<td width="45%">Description</td>
<td width="15%">Unit Price</td>
<td width="15%">Amount</td>
</tr>
</thead>
<tbody>
<!-- ITEMS HERE -->
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<!-- END ITEMS HERE -->
<tr>
<td class="blanktotal" colspan="3" rowspan="6"></td>
<td class="totals">Subtotal:</td>
<td class="totals cost">&pound;1825.60</td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">&pound;18.25</td>
</tr>
<tr>
<td class="totals">Shipping:</td>
<td class="totals cost">&pound;42.56</td>
</tr>
<tr>
<td class="totals"><b>TOTAL:</b></td>
<td class="totals cost"><b>&pound;1882.56</b></td>
</tr>
<tr>
<td class="totals">Deposit:</td>
<td class="totals cost">&pound;100.00</td>
</tr>
<tr>
<td class="totals"><b>Balance due:</b></td>
<td class="totals cost"><b>&pound;1782.56</b></td>
</tr>
</tbody>
</table>


<div style="text-align: center; font-style: italic;">Payment terms: payment due in 30 days</div>


</body>
</html>
';

include("MPDF57/mpdf.php");




$mpdf = new mPDF(
   '',    // mode - default ''
   'A4',    // format - A4, for example, default ''
   0,     // font size - default 0
   '',    // default font family
   10,    // margin_left
   10,    // margin right
   30,    // margin top
   10,    // margin bottom
   5,     // margin header
   10,     // margin footer
   'L'    // L - landscape, P - portrait
);

$mpdf -> AddPage();


$mpdf->SetProtection(array('print'));
$mpdf->SetTitle(" Invoice");
$mpdf->SetAuthor("");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');

$mpdf->WriteHTML($html);

$mpdf->Output();
the first header is displayed in first page only. but the second header table displayed all pages.
need help.

.pdf   mpdf (1).pdf (Size: 54.99 KB / Downloads: 0)

Image uploading by api to android mobile

$
0
0
Hi

   I had a issue regarding uploading a image from android mobile.The image is uploading and storing in database from website but not from mobile app.From mobile the image is not inserting into database .So,Please help me to resolve the issue.Thank you in advance.



Code in api in view
<?php 
require('includes/config.php');
$api = new Settings();
//echo "<pre>"; print_r($_FILES); die;
$mydb = new myDBC;
$api->validation('blank', array(user_id =>$json_parse_array[xxx]['user_id']));

$menu_id = $json_parse_array[xxxx]['menu_id'];
$category_id = $json_parse_array[xxxx]['category_id'];
$image = base64_decode($json_parse_array[xxxx]['pro_image']);
$is_active ='1';

$path = '../images/product/';
$fileName = 'products_'.time().'.jpg';
$final = $path.$fileName;

 file_put_contents($path . $filename, $image);

if(move_uploaded_file($_FILES['pro_image']['tmp_name'], $final)){
$file = 'http://xxxx.com/images/product/'.$fileName;
// $api->response(SUCCESS, "Find image name.", array('fileName'=>$file));
}
   
 $qry = "INSERT INTO `dz_products`(`menu_id`, `category_id`,`pro_image`,`is_active` ) 
VALUES('$menu_id','$category_id','$file','1')";
//print_r($qry);

    $result = $mydb->runQuery($qry);
    $result_array=array($result);
   
   
   
        $last_id = $mydb->lastInsertID();

Alternative for DataTables-Live-Ajax?

$
0
0
Hi,

I want to have a table showing data from the database and constantly updating the columns (ex: status, time, date, etc.). In other words, real time.

I found this DataTables extension. You can look for it here: https://github.com/jhyland87/DataTables-Live-Ajax
I like the use of this library. It will update only the specific rows if changes are detected.

Now, clearly it is no longer maintained. But I  gave it a shot.

The problem: After I refreshed the page, on the first ajax request, the data is shown on the table. On the next Ajax request (poll) made by the library, it didn't send any parameters except the timestamp (ex: ?_=1545040854915), thus throwing an exception on server side.

I followed the instructions. Replicated the examples. Still no success.

I don't want to use this library anymore. It's frustrating. Does anyone know an alternative DataTables extension/library? Thank you.

Cannot get the right encryption MYCRYPT

$
0
0
Using the old encrypt function that I wrote in CI2 with PHP 5.6


I get the result like this 

tgpzkS8fLTcuYW1XQtYoVQ%3D%3D  (Correct)


Code:
$amount = 1100;

[size=small][font=Monaco, Consolas, Courier, monospace]$json = array([/font][/size]
[size=small][font=Monaco, Consolas, Courier, monospace]'Amount' => $amount[/font][/size]
);

$data = json_encode($json);

function encrypt($data, $secret) 

  //Generate a key from a hash 
    $key = md5(utf8_encode($secret), true); 
    $data2 = utf8_encode($data); 
    $iv = utf8_encode("jvz8bUAx"); 
    
    //Take first 8 bytes of $key and append them to the end of $key. 
    $key .= substr($key, 0, 8); 
   
    //Pad for PKCS7 
    $blockSize = mcrypt_get_block_size('tripledes', 'cbc'); 
 
    //Encrypt data 
    $encData = mcrypt_encrypt('tripledes', $key, $data2, MCRYPT_MODE_CBC, $iv); 
      
    return urlencode(base64_encode($encData)); 


After I upgraded my project to CI 3 with PHP 7.1

The result I get now is. N4iCloGQTBn%2Fp5sUAK7OwFR3QBY57fsr  (Wrong)


Code:
$this->load->library('encryption');

$key = md5(utf8_encode($secret), true); 
$key .= substr($key, 0, 8); 
$iv = utf8_encode("jvz8bUAx"); 

$amount = 1100;

$json = array(
'Amount' => $amount
);

$data = json_encode($json);

$params = array(
        'driver' => 'mcrypt',
                'cipher' => 'tripledes',
                'mode' => 'cbc',
                'key' => $key,
                'hmac' => false
        );

$ciphertext = $this->encryption->encrypt($data, $params);
$ciphertext = urlencode(base64_encode($ciphertext));

return $ciphertext;

Can you help me how can I return same result just like above in my current tasks?
Also, how do I set up my IV value? 


Thanks,

Email package protocols

$
0
0
We are in the process of modernizing the Email package - having it use exceptions, using the adapter process for different mail transport programs, and thorough unit testing. The CodeIgniter 3 Email supported three "protocols": mail, sendmail, and SMTP. We want to guage the relative importance of each of these to the CodeIgniter community, and have made a poll attached to this thread to measure that.

One of the goals for CodeIgniter 4 is unit testing & code coverage. We have a solution planned for the SMTP handler: using mailcatcher. We don't have a similar solution in mind for "mail" or "sendmail". If you have suggestions, please mention them in a post in this thread.

Thanks!

Bug v3.1.9 MY_Controller

$
0
0
I define __constructor function inside MY_Controller class extends CI_Controller, just write
Code:
echo 'Hello World'
then I extends it to Home Controller, write index at Home Controller then just run it in my browser. Unfortunately, it just blank, so I try to create public variable in MY_Controller, assign it with a few string through the __constructor, var_dump it through index at Home controller, it just show null, can anybody help me, tks

this is my code 

core/MY_Controller.php

PHP Code:
class MY_Controller extends CI_Controller
{
 
   public $foo;

 
   public function __constuct()
 
   {
 
       parent::__constuct();
 
       
        $this
->foo 'Helloooow';
 
   }


controller/Home.php
PHP Code:
<?php

class Home extends MY_Controller
       
    public 
function index()
 
        
        var_dump
($this->foo );
 
      



the result is null

Hard working

$
0
0
I just downloaded and install codeigniter 3.1.9 but it is quite hard for my computer run.. what is it happen?
I saw this file is not big enough :3

Axios POST requests and Ci security class

$
0
0
Ha anybody experience wtith using axios with CI?
Axios POST  requests are received via PHP's input stream, not in the usual POST array. As such, the regular method for CSRF prevention here do not work. The only workaround is to add my URL endpoint to $config['csrf_exclude_uris'] array.

If I have lots of endpoints I wish to call client-side via axios, that would become a large array.

I there anywhere to have CI's security class recognise the CSRF name and hash pair, when received via input stream

CI v1.5.4 Session question

$
0
0
Hey everyone, I am quite new to CI and have inherited a large Oracle implementation that uses a very old version of CI (a dump of the CI_VERSION= 1.5.4) to which i cannot find documentation for at all. It looks like the version i am forced into isn't even a stable release?

The problem is my hands are tied with regards to upgrading this to new version and the project itself goes EoL in a year. However I have been tasked with a change that requires me to dig in deep. 

What I am trying to do is simply get a list of all of the CI session variables that are in play. It seems that around CI v2 they implemented a much easier way to do this in the session.php file with the added function all_userdata() as well as store the CI variables in the $_Session php object. In my current attempts I have tried to dump out $_Session which is empty, i have also tried with not much luck to extend the current session class with a newer version of session.php in the hopes i can just get the variables to dump out once.(I do not have permissions to modify the current session.php or I would just stuff the all_userdata function in there for a 1 time dump) I really just need the name of the key so that i can fetch it later. I have 3 variables that are being passed through, and i have 'guessed in the dark' at the first 2 keys and got lucky. However i cannot for the life of me figure out what they used for the third one.  

My problem is really that the core code is read only and buried in an oracle stack with most of my permissions limited. I can modify files at the top end of the stack, but the core architecture is off limits (requests for access denied and not owned by me).

Im really hoping someone has a way to just list out the current CI userdata, im ok with hacky solutions because the data IS coming back when i use the getSessionData($key) function with a correct key.

anyways, cheers all, hopefully someone remembers back this far in history and has a solution. If not, thanks for taking the time to read this.

How implement cache on Search query sql

$
0
0
Hi guys,


I need to be able to cache all kinds of searches with like.
I have it this way, according to the documentation, but according to the profiler, it doesn't save in cache and the query is still running.


SearchModel
PHP Code:
public function search($product)
 
   {
 
       $this->db->cache_on();
 
       $data $this->db
            
->select('name, slug')
 
           ->from('products')
 
           ->like('name'$product)
 
           ->or_like('slug'$product)
 
           ->limit(5)
 
           ->get()
 
           ->result_array();
         
$this->db->cache_off();

 
       return json_encode($data);
 
   

SearchController:
PHP Code:
public function index($product)
 
   {
 
       $product urldecode($product);
 
       $product preg_replace('/\s+/''-'$product);
 
       $this->load->Model('api/search/SearchModel');

 
       echo $this->SearchModel->search($product);

 
       $this->output->enable_profiler(TRUE);
 
   

[Image: 7152dc383ed4e975467591358008d7db.png]


Directory application\cache is empty...
[Image: 9b422656b418d1b101dce28e2487181a.png]

CI tutorial from David Connelly

$
0
0
Hello,

David Connelly did a massive tutorial of 135 videos on Youtube on how to build a ecommerce website with CI 3 and I was in the middle of following it. a week ago he decided to move on and deleted 1/3 of the video.

I wanted to ask the commnunity if someone ever downloaded the entire videos (along with any code source) on their computer. I would appreciate a link to a dropbox folder for example so I can download the missing video.

An immensce thank to the CI community.

CI Session - Lost connection to MySQL server during query

$
0
0
My site is working fine but sometimes it suddenly starts giving CI_SESSION error...

Error is : 


Code:
ERROR -> Query error: Lost connection to MySQL server during query - Invalid query: SELECT `data`
FROM `ci_sessions`
WHERE `id` = '44278e7a05ed07842bgf15b1a5feaff0dcee76c3'

ERROR --> Query error: MySQL server has gone away - Invalid query: INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('21440e7a66ed02342bbf15b1a3feaff0dcee76c3', 'xxx.xx.xx.xx', 1545006351, '')

ERROR - --> Query error: MySQL server has gone away - Invalid query: SELECT RELEASE_LOCK('5d966d065ca3606e9cdf23c761035e54') AS ci_session_lock

 Please let me know if anyone has any idea about this...
 
 My config setting is : 

Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_driver'] = 'database';

Flashdata Not Passing Message in CodeIgniter 3

$
0
0
Hello.

We are in the process of updating our website from CodeIgniter 2 (.1.1) to CodeIgniter 3 (.1.9).

We use the set_flashdata() method to set a message to be displayed on redirect in numerous places in our code.  When the redirect occurs, the message disappears.  This was working fine in our original CodeIgniter 2 application.

It should be noted that this only occurs when there is a redirect (i.e., index.php file to run from the beginning).  If we reload the view without redirecting, the flashdata shows up correctly. 

I tried using keep_flashdata(), but it did not work.

I was wondering if perhaps this has to do with the way the new Session class works.

Any help would be greatly appreciated!
Viewing all 14066 articles
Browse latest View live


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