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

Ci_session with database or without database which one is more efficient

$
0
0
Ci_session with database or without database which one is more efficient. My requirement is high performance in multiple database connection (db connection depends on user login type).

Group by Query help from multiple tables

$
0
0
Hello,

I need help in a query from multiple tables.

Here are the table names:-

products 
images (for product's images)
users

  1. I need the query to return result as 4 products per user but maximum 3 users.
  2. and calculate the total number of products per user.
As show in the picture:-
[Image: RcS8D3s.png]


Here is the query I have been trying:-

Code:
public function random_three_sellers(){
   $this->db->select(
     'p.id as p_id, p.slug as p_slug, p.title as p_title, p.user_id as p_uid, p.status as p_status,
     u.id as u_id, u.username as u_name, u.slug as u_slug, u.email_status as u_estatus, u.banned as u_ban,
     i.product_id as i_pid, i.image_small as i_ism
     ');
   $this->db->where('p.status', 1);
   $this->db->from('products p');
   $this->db->limit(12);
   $this->db->join('images i','i.product_id = p.id', 'left');
   $user_array = array('u.banned' => 0 , 'u.email_status' => 1);
   $this->db->where($user_array);
   $this->db->join('users u','u.id = p.user_id', 'left');
   $this->db->group_by('p_uid');
   $query = $this->db->get();
   // var_dump($query);
   // die();

   if ($query->num_rows() > 0) {
     return $query->result_array();
   }else{
     return false;
   }
 }
 
3. Is it possible to add total number of followers per user. This data is in another table named "followers" , the column is "following_id"

4. Finally, how to show them in the view's loop?

Please ask me if any more info is required for the solution.


Regards.

Learn

$
0
0
Can anyone tell me how to learn MY SQL. Please share link or documents related to it.

Trackback ?

$
0
0
I discovered another CI3 class that has fallen through the cracks in the move to CI4: the Trackback library.
Do any in the community use this and/or have a need for it?

Thanks

Get controller and method in view

$
0
0
Hy  there . How to get current controller  and method from view file ?

Automatic assignment of 0777 access permissions

$
0
0
You can use the module installer from the Yii framework to copy files and set access permissions to files and directories. It is well suited for this task, for it is an independent package that does not require the Yii framework, nor any other libraries.

Example of composer.json configuration:

PHP Code:
"require": {
 
   "yiisoft/yii2-composer""^2.0" 
}, 
"scripts": {
 
   "post-create-project-cmd": [
 
       "yii\\composer\\Installer::postCreateProject"
 
   ]
}, 
"extra": {
 
   "yii\\composer\\Installer::postCreateProject": {
 
       "copyFiles": [
 
           {
 
              "environment/.env"".env" 
 
           }
 
       ], 
 
       "setPermission": [
 
           {
 
               "writable/cache""0777",
 
               "writable/debugbar""0777",
 
               "writable/logs""0777",
 
               "writable/session""0777",
 
               "writable/uploads""0777"
 
           }
 
       ]
 
   }


Read more

email send error

$
0
0
I developing a website, where in an admin page have a button which processing an email send (to admin).

This is the configuration:


PHP Code:
   $this->load->library('encrypt');
 
   $config = array(
 
       'protocol' => 'smtp'// 'mail', 'sendmail', or 'smtp'
 
       //'useragent' => 'CodeIgniter',
 
       'smtp_host' => 'smtp.mail.yahoo.com',
 
       'smtp_port' => 465,
 
       'smtp_user' => '****',
 
       'smtp_pass' => '****',
 
       'smtp_crypto' => 'ssl'//can be 'ssl' or 'tls' for example
 
       'mailtype' => 'html'//plaintext 'text' mails or 'html'
 
       'charset' => 'iso-8859-1',
 
       'wordwrap' => TRUE,
 
   );
 
   $this->load->library('email'$config); 

I try with different configurations:
  • gmail with SSL, with TLS, with different 'smtp_host' like with and without ssl://
  • different gmails with @gmail.com and with another one which is not @gmail.com
  • yahoo mail with ssl
  • different PHP versions like 5.6 and 7.1
  • enable less secure apps in gmail/yahoomail
And this is the function:

PHP Code:
 public function send_email(){
 
   $from $this->config->item('smtp_user');
 
   $to '****';

 
   $this->email->from($from);
 
   $this->email->to($to);
 
   $this->email->set_newline("\r\n");
 
   $this->email->subject('szerkesztési jog igénylése');
 
   $this->email->message(
 
     'Tisztelt adminisztrátor!\r\n
      \r\n
      Egy felhasználó szerkesztési jogot szeretne igényelni a Faipari szakszótárhoz\r\n
      Kérjük jelentkezz be, és bíráld el a szerkesztési jogát az igénylőnek'
 
   );

 
   if ($this->email->send()) {
 
     $this->session->set_flashdata('uzenet''Sikeres szerkesztési jog igénylés');
 
     redirect('pages/user'$data);
 
   } else {
 
     show_error($this->email->print_debugger());
 
   }
 
 
I got different error codes for different cases, but nothing made solution after few hours google search and reading threads.


With yahoo/ssl:

Quote:Severity: Warning
Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Filename: libraries/Email.php

Severity: Warning
Message: fsockopen(): Failed to enable crypto

Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.mail.yahoo.com:465 (Unknown error)

The following SMTP error was encountered: 0
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

With gmail/ssl:

Quote:A PHP Error was encountered
Severity: Warning
Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

With gmail/tls:

Quote:A PHP Error was encountered
Severity: Warning
Message: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

An Error Was Encountered
220 smtp.gmail.com ESMTP u9sm5539564wmd.14 - gsmtp

Have you any idea what can solution this problem? My codeigniter version is 3.1.7

Updating Model with a unique field?

$
0
0
Hi guys

Just working on an update in the model controller and have hit a snag.

I have setup one of the fields as unique, when I try an update, it always fails, unless that particular field has changed and is still unique.

Is there a way to temporarily turn off the unique check based on if it has changed or not? because I may not want to change that field.

Thanks

image files from javascript

$
0
0
Greetings, 

I'm continuing some existing projects referencing images via Javascript files e.g.
var images=["<img src='/images/chicken.png'>","<img src='[b]/images/pig.png'>"][/b]
Is it possible to reference these directly from Javascript files located in the assets folder i.e. C:\xampp\htdocs\game\assets\images just for demo purposes, not best practice.
 Cheers

EMAIL ATTACHMENT NOT SHOWN ON APPLE MAIL APPS

$
0
0
Hi guys, here i want to ask about this error 
I use CI for my emailing invoice with .pdf attachment, but i dont know why the email not shown the attachment and show some "weird" language here

anyone can help me?
thanks

[Image: klpdIsP]

Multi Upload return TRUE

$
0
0
Hi CI Members,

I have issue when I submit form without upload any image and system not detect the input is empty,
But when I remove "[]" in name is work.

I hope CI Members can help me to solve my issue.

Code:
<input type="file" class="form-control-file" id="preview_image" name="preview_image[]" multiple>


PHP Code:
if (isset($_FILES['preview_image']['name'])
 
       && ($_FILES['preview_image']['name'] != '' || is_array($_FILES['preview_image']['name']) && count($_FILES['preview_image']['name']) > 0)) {
 
       if (!is_array($_FILES['preview_image']['name'])) {
            
            
//Upload Code
    
}

 
   return (bool) $totalUploaded

Thanks you...

Metallo.id - A Multi-purpose Content Management System

$
0
0
Metallo.id is an Open-source Multi-purpose Content Management System.

Current Metallo.id CORE version: 0.1.0 (Not suitable for production)
Framework: CodeIgniter 4.0.0-beta.2

Metallo.id CORE Features:
- Administrators & Administrator Groups
- Users & User Groups
- Filemanager
- Front-end Theming System
- Menu System
- Widget System (Available widgets: Blank, Horizontal Divider, HTML, Jumbotron)
- Static Widget System (Available static widgets: User account, Search, Language selector, Theme Switcher)
- Layout System
- Module System
- Website Settings
- Supports Multi-language
- Information Pages
- CORE, Modules, Themes Updater System
- Error Logs

Available Metallo.id Modules:
- Metallo.id Module: Page. Useful for creating pages for your Metallo.id-powered website.
- Metallo.id Module: Post. Useful for creating news/blog for your Metallo.id-powered website.
- Metallo.id Module: Forum. Experimental module. Still lack of functionalities. Useful if you want to run a forum on your Metallo.id-powered website.

Important Note: No email library yet. So, email-related functionalities, such as: email verification, forgotten password, newsletter, etc, have not been developed yet.

Downloads, Report an Issue, Documentations (in progress)
https://dev.metallo.id/


Best Regards,
Metallo.id

CodeIgniter 4.0.0-beta.3 released

$
0
0
CodeIgniter-4.0.0-beta.3 launches today [Image: smile.gif]

This is a pre-release of 4.0.0. It is not suitable for production! (but it is pretty darn close)

Highlights:
  • Fixed a number of model, database, validation & debug toolbar issues
  • Type hinting added throughout & typos corrected (see API docs)

New messages:
  • Database.FieldNotExists
  • Validation.equals, not_equals

App changes:
  • Removed $salt config item in app/Config/App
  • Enabled migrations by default in app/Config/Migrations
  • Simplified public/.htaccess

Check the changelog for details, and the installation writeup for further directions.
Looking to upgrade from CI3 to CI4?
Generated API docs accessible at https://codeigniter4.github.io/api/

We hope this will be the last beta round, and that you can look forward to the first release candidate next!
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. Instead, use the appropriate CodeIgniter 4 subforum. We are trying to make the best of the limited resources that we have!

Thank you, and ENJOY!

the created model does not work 'User'

$
0
0
Hello, friends!

dump: 
Code:
CREATE TABLE IF NOT EXISTS `user` (
 `id_user` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `login` char(50) DEFAULT NULL,
 `name` char(50) DEFAULT NULL,
 `email` char(50) DEFAULT NULL,
 `password` char(255) DEFAULT NULL,
 `ip` char(15) DEFAULT NULL,
 `created_at` int(10) unsigned NOT NULL DEFAULT '0',
 `updated_at` int(10) unsigned NOT NULL DEFAULT '0',  
 PRIMARY KEY (`id_user`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

INSERT INTO `user` (`login`, `name`, `email`, `password`, `ip`,`created_at`,`updated_at`) VALUES
('test','Ivan','aaaa@bbbb.com','e1r1e1','10.0.0.1', 1457950515,1457950515);

app\Models\UserModel.php:
Code:
<?php namespace App\Models;

use CodeIgniter\Model;

class UserModel extends Model
{
    protected $table      = 'user';
       protected $primaryKey = 'id_user';

       protected $returnType = 'array';
       protected $useSoftDeletes = true;

       protected $allowedFields = ['login','name', 'email'];

       protected $useTimestamps = true;
       protected $createdField  = 'created_at';
       protected $updatedField  = 'updated_at';
        protected $dateFormat     = 'int';
        
       protected $validationRules    = [];
       protected $validationMessages = [];
       protected $skipValidation     = false;
}

 
app\Controllers\Home.php :

Code:
<?php namespace App\Controllers;
// *LINK REDACTED*
use CodeIgniter\Controller;
use App\Models\UserModel;

class Home extends BaseController
{
    
    puplic function index()
    {
       
        $userModel = new UserModel();
        $user_id = 1;
        $user = $userModel->find($user_id);
    }
}

Result:

Whoops!

We seem to have hit a snag. Please try again later...

--------------
Help me!

query mysql berdasarkan user yang sedang login

$
0
0
haloo saya mau bertanya ini saya ingin menerapkan code mysql pada codeigniter dan saya rasa,
saya memiliki kesalahan pada bagian "t.USER = $this->session->userdata('user_id');"
yang saya harapkan pada query tersebut yaitu untuk menampilkan data berdasarkan user_id, sesuai user yang sedang login.

mohon bantuannya.

code codeigniter
------------------------------------------------------

Code:
function get_rekomen()
{
$query = $this->db->query("SELECT
c.*,
t.produk_id,
t.id_transdet,
t.kategori_id,
t.total_qty,
t.USER
FROM
transaksi_detail AS t
LEFT JOIN
(
SELECT
g.id_produk,
p.slug_produk,
p.foto,
p.foto_type,
p.harga_diskon,
p.diskon,
p.harga_normal,
p.judul_produk,
g.kat_id,
k.judul_kategori
FROM
(
SELECT
MAX(m.id_produk) AS id_produk,
m.kat_id
FROM
produk AS m
GROUP BY
m.kat_id
)
AS g
INNER JOIN produk AS p ON p.id_produk = g.id_produk
LEFT JOIN kategori AS k ON k.id_kategori = g.kat_id
)
AS c
ON c.kat_id = t.kategori_id
WHERE
t.USER = $this->session->userdata('user_id');
ORDER BY total_qty DESC limit 1")->result();

return $query;
}

----------------------------------------------------

HELP need programmer.

$
0
0
Hello I have a client that has a site designed in CodeIgniter and I need technical assistance to be able to modify the site.


Carlos.

Where to place functions that work with database

$
0
0
Hi guys,

I'm sure this is a very remedial question, but I'm not quite sure what is best-practice here.

I have one model for each table in my database, and I have a controller that does a lot of calculations involving data from many tables.  I'd like to create a bunch of functions to make my code cleaner (and hopefully take some of the code out of the controller).

I thought to use helper functions, but I wasn't sure how to access database objects in the helper functions; since my "use" statements are in the controller.

Thanks,
Phil

trying to call javascript

$
0
0
I realize that js is really a client thing and not a server thing. Anyway, I am trying to call 


Code:
$(register_extension(
   var editorExtensionId = "mebiphcpglaighebopfapfoiimgnnbpf";

   // Make a simple request:
   chrome.runtime.sendMessage(editorExtensionId, "snapshot_mode",
       function(response) {
           if (!response.success)
                  handleError(url);

})
I try to load it with 

PHP Code:
$this->load->js("/js/javascript_funcs_extensionloaded.js");
javascript_funcs_extensionloaded(); 
I am getting:

A PHP Error was encountered

Severity: Error

Message: Call to undefined function javascript_funcs_extensionloaded()

Filename: controllers/Configure.php
Line Number: 43

Can anyone tell me how to look at this? 

POST input is empty if contains accented characters.

$
0
0
Hi there folks.

I'm trying to debug a CI app to a friend of mine. The issue is that $this->input->post('name'); is empty if a accented character is sent.
Eg.:

If I send the name as Testing, then the value of $this->input->post('name'); is also Testing.
But if I send the name as Accentuátion (or anything with special accent characters), the the value of $this->input->post('name'); is "" (empty).

Any clue of what might be causing this issue of how to fix it?


Thanks!

Help with domain xfer stuff

$
0
0
Hi all,

I'm building a website for a guy and currently we are hosting on an instance on Amazon Lightsail to keep costs down.

The client has purchased a couple domains and they are parked over on GoDaddy.   I'd like to transfer them to AWS both from a management standpoint but also have them point to our Lightsail instance.

I also would like to setup AWS Simple Email Service to work with the domain so our site can email out and we can receive inbound emails at our domain.com.   

Quite frankly I find the transfer process to Amazon to be a little over my head.  Wondering if there is someone that can lend a little help in getting this done.  I think the client is willing to pay a little but we are on a tight budget.

Please email me at:  markholbrook@fastmail.net

If you can help.

Mark
Viewing all 14353 articles
Browse latest View live


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