codeigniter

PHP父类调用子类方法,CodeIgniter中DB的继承关系

孤街浪徒 提交于 2020-03-17 01:54:46
某厂面试归来,发现自己落伍了!>>> 先看几行代码: <!-- lang: php --> class A { private $b; function __construct($a){ $this->b = $a; } function func1(){ var_dump($this->b); } function func2(){ $this->funcb(); } } class B extends A { function funcb(){ var_dump("b"); } } $a = new B('a'); $a->func1(); $a->func2(); 这几行代码是没有错误的,在父类中调用子类的方法,子类实例化之后可以正常工作。 CI的DB部分正是使用了这种方式来封装数据库操作。 CI的DB函数的写法正是先加载 CI_DB_driver 这个基类,然后检查active record是否开启,如果开启则 <!-- lang: php --> class CI_DB_active_record extends CI_DB_driver 然后 <!-- lang: php --> class CI_DB extends CI_DB_active_record 否则 <!-- lang: php --> class CI_DB extends CI_DB_driver

mysqli::real_connect(): (HY000/1049): Unknown database error in codeigniter

不羁的心 提交于 2020-03-14 05:17:46
问题 I'm new to Codeigniter PHP framework. When I'm testing my application I get 'Unknown database db_name' error. I have browsed through several sites but didn't found solution for the problem as I'm trying the same to connect with wamp's mysql database. Any help would be appreciable. Following is database.php in config folder: image describing Test database: $active_group = 'default'; $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root',

mysqli::real_connect(): (HY000/1049): Unknown database error in codeigniter

橙三吉。 提交于 2020-03-14 05:16:00
问题 I'm new to Codeigniter PHP framework. When I'm testing my application I get 'Unknown database db_name' error. I have browsed through several sites but didn't found solution for the problem as I'm trying the same to connect with wamp's mysql database. Any help would be appreciable. Following is database.php in config folder: image describing Test database: $active_group = 'default'; $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root',

Export and download my php table data to csv

帅比萌擦擦* 提交于 2020-03-06 10:25:38
问题 I'm trying to get my datbase fetched data to Excel file for downloading it in execl or csv, but I'm having problems with exporting and also No datas are fetching to the csv .Here is my code: This is my php code <?php $connect = new PDO('mysql:host=localhost;dbname=123', '123', 'invoice123'); $query ="SELECT * from tbl_order"; $result = mysqli_query($connect, $query); ?> this is my html <form method="post" action="export.php" align="center"> <input type="submit" name="export" value="CSV Export

codeigniter ActiveRecord where statement issue

好久不见. 提交于 2020-03-06 09:15:37
问题 is have this statement and i want to make it by the Active Records way in codeigniter DELETE FROM TABLE (col1 = value AND col2 = value2 ) OR (col1 = value2 AND col2 = value ); 回答1: CodeIgniter Active Record is impractical for mixing AND's and OR's within a query. You will likely need to construct some of the query manually, e.g. something along the lines of: $this->db->where("col1 = $value AND col2 = $value2"); $this->db->or_where("col1 = $value2 AND col2 = $value"); Alternately, in your

Unable to open zip file, codeigniter

核能气质少年 提交于 2020-03-05 09:37:09
问题 I tried to add my pictures, which uploaded by users, into a zip file. so, that user can download this file. The problem is when I download this zip file, it contains lots of filename (as I expect). But when I open this zip, it show me error “C:....ata\Local\Temp\my_photo.zip: Unexpected end of archive” Each picture has size but CRC32 is 00000000 Here is the code: $this->load->library('zip'); $this->zip->clear_data(); foreach ($row as $ar){ $file_relative_path = $ar->filepath; if(file_exists(

Order by “multiplication” in code igniter query builder

馋奶兔 提交于 2020-03-05 07:27:31
问题 I got the following tables in my database Product(product_id,title,sale_price,tax_id) Tax(Tax_id,label,rate) I'm trying to show a list of products ordered by product.sale_price*tax.rate How can I achieve that with Code Igniter For the moment, my code looks like this : $this->db->order_by('sale_price', 'asc'); $this->db->get('product'); And I tried to do something like this in SQL, but it doesn't work. SELECT * FROM product inner join tax on product.tax_id = tax.tax_id ORDER BY (product.sale

Codeigniter “require(./vendor/autoload.php): failed to open stream” error just if it is run by cronjob - not a composer problem apparently

狂风中的少年 提交于 2020-03-05 03:04:26
问题 This is a consequent question of another one that can be found at Not working shared hosting cPanel cronjob under Codeigniter and it is worth to be asked apart. This is the context: codeigniter framework is used scheduler is defined as a controller and called by a cronjob the web server is a shared hosting managed with cPanel the cronjobs work properly if defined as pure PHP ones outside codeigniter the schedule controller if is called by the browser directly work fine: https:/

image uploading works properly with all devices except iphone

匆匆过客 提交于 2020-03-05 00:26:55
问题 php (codeigniter): image uploading working properly in all devices but on working on iphone devices Only iphone-captuered images are getting uploaded, but not working for non-captured/other images My Code Snippet: (too lengthy code, I am just some part of that code) <?php ..... ..... $this->load->library("upload"); $this->upload->initialize($this->set_upload_options()); if($this->upload->do_upload()){ $ppimagedata = $this -> upload -> data(); $ppnewimagename = $ppimagedata["file_name"]; $this

stop page load in codeigniter jquery + ajax bookmark function

自作多情 提交于 2020-03-04 23:07:13
问题 I'm working on a bookmarking function (codeigniter, jquery, ajax). Below is the HTML for the form and the jQuery code. Here's what's happening: form is submitting the data to the database the page is reloading I'm not getting the success alert If I use e.preventDefault() or return false, the page doesn't reload and I get the success alert, but the data that gets passed to the database is 0. HTML FORM <?php echo form_open('bookmarks/addBookmark'); ?> <?php echo form_hidden('bookn', $bname); ?>