codeigniter

php codeigniter

喜欢而已 提交于 2019-12-25 18:13:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1、CI是什么 CI的全称是CodeIgniter, 一个小巧但功能强大的 PHP 框架,作为一个简单而“优雅”的工具包,它可以为 PHP 程序员建立功能完善的 Web 应用程序。基于MVC设计模式,轻量易学,注重安全,文档健全,有丰富的类库。 2、CI能做什么 CI提供了许多丰富的类库,比如文件上传、图片处理、文件压缩、邮件发送等。这些类库的存在大大减低了开发的难度与周期,也减少了整合外部类库的需求。能快速高效的开发各种web应用: 比如电子商务网站、SNS、论坛、内容管理系统(CMS)、客户关系管理系统(CRM)等等。 3、MVC 入口文件:唯一一个让浏览器直接请求的脚本文件 控制器controller:协调模型和视图 模型model:提供数据,保存数据 视图view:只负责显示、表单... 动作action:是控制器中方法,用于被浏览器请求 4、CI中的mvc 访问url使用的是pathinfo:入口文件.php/控制器/动作 application目录中:controllers(控制器)、models(模型)、views(视图) 5、c(控制器)。 不需要加后缀; 文件名全部小写(例如:user.php); 所有控制器,直接或间接继承自CI_Controller类; 控制器中,对动作(方法)要求

使用 CodeIgniter 框架快速开发 PHP 应用(七)

北城余情 提交于 2019-12-25 18:12:51
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> CodeIgniter 和对象 这是玩家章节。它讲述的是 CodeIgniter 的工作原理,也就是揭开CI头上'神秘的面纱'。如果你是 CI 的新手,你可能想要跳过它。不过, 迟早, 你可能想要了解CI的幕后在发生什么 ,为什么不真正的玩转它呢? 当我刚开始使用 CodeIgniter 的时候,对象使我迷惑。 我是在使用 PHP 4的时候接触CI的, PHP4并不是真正的面向对象的语言。我在一大堆对象和方法、属性和继承,还有封装等数据结构中转悠,总是被类似的出错信息包围 " 调用非对象的成员函数". 我如此频繁地看到它们,因此我想到要印一件T恤衫,上写: 神秘,无规律可循, 而我仿佛正穿着它站在一个现代艺术展会的会场上。 这一章的内容包含CI使用对象的方法, 和你OO编程的方法。 顺便说一下,术语 '变量/属性', '方法/函数'是等义的,当 CI 和 PHP 经常会混着使用它们。比如,你在你的控制器中写一个 '函数', 纯 OO 程序员会称他们是'方法'。你称之为类的变量而纯OO程序员会叫它们‘属性’。 面向对象编程 我正在假定你和我一样有 OOP 的基本知识, 但如果只是在PHP4中尝试过可能还不太够。 PHP 4 不是一种 OO 语言, 虽然具备了一些 OO 的特征。 PHP 5 会更好一些,

定义默认控制器

烈酒焚心 提交于 2019-12-25 17:50:17
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> CodeIgniter可以设置一个默认的控制器,当URI没有分段参数时加载,例如当用户直接访问你网站的首页时,打开 application/config/routes.php 文件,通过下面的参数指定一个默认的控制器: $route['default_controller'] = 'blog'; 其中,“Blog”是你想加载的控制器类名,如果你现在通过不带任何参数的 index.php 访问你的站点,你将看到你的“Hello World”消息。 来源: oschina 链接: https://my.oschina.net/u/4225107/blog/3147330

Codeigniter and AJAX retrieving/getting data from database error

大憨熊 提交于 2019-12-25 17:14:08
问题 I always land into the error function in ajax, what is the problem here? I want to retrieve a img url stored in the database and append it using jquery to show my img gallery. But before I can do any of this, I have to make sure it always land on the success function, but I always land on error function... so I can not proceed and I am stuck here, UPDATE: check the console, it says SyntaxError: missing : after property id on success:function(result) My script: function load_contents(track

Codeigniter Pagination bug

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 17:06:38
问题 I think that there is a bug in the codeigniter pagination library. For some reason when I generate the pagination links, it generates the links as: 1 2 3 4 Where page 3 is linking to 4 . Here is the config variables code in case anyone is curious: $config['base_url'] = base_url() . "index.php/test/$query_string"; $config['total_rows'] = $search_results->num_rows(); $config['per_page'] = $items_per_page; And here is a sample of my query string: ?q=sample_query_string&per_page=1 Is there a way

Call to member function result() of non object codeigniter

随声附和 提交于 2019-12-25 17:03:22
问题 public function get_priority($priority_id = "") { if ($priority_id == "") { $qry = $this->db->get("tm_priority"); } else { $qry = $this->db->query("SELECT * FROM tm_priority WHERE nt_id = {$priority_id}"); echo $this->db->last_query(); } print_r($qry->result()); } In my above model function I echo the last_query() for debugging purpose and it's giving me the following result SELECT * FROM tm_priority WHERE nt_id = 1 When I run this query directly into my mysqlyog, it's working fine. Then what

Call to member function result() of non object codeigniter

半世苍凉 提交于 2019-12-25 17:02:11
问题 public function get_priority($priority_id = "") { if ($priority_id == "") { $qry = $this->db->get("tm_priority"); } else { $qry = $this->db->query("SELECT * FROM tm_priority WHERE nt_id = {$priority_id}"); echo $this->db->last_query(); } print_r($qry->result()); } In my above model function I echo the last_query() for debugging purpose and it's giving me the following result SELECT * FROM tm_priority WHERE nt_id = 1 When I run this query directly into my mysqlyog, it's working fine. Then what

BackboneJS + Codeigniter pushState true not working

假如想象 提交于 2019-12-25 16:55:29
问题 So I have this Backbone App where I use Codeigniter for the Backend. For some reason, pushState:true does not work. So, my main.js of my backbone app has this: Backbone.history.start({ pushState: true, root: App.ROOT }); My app.js has this: var App = { ROOT: '/projects/mdk/' }; and my navigation module, which renders the menulinks, each item has this: this.insertView(new ItemView({ model: new Navigation.ItemModel({ href: App.ROOT + 'home', class: 'home', triggers: 'home', route: this.route })

fgetcsv not reading csv file properly that is saved in linux system

笑着哭i 提交于 2019-12-25 16:46:50
问题 I'm trying to import some data through csv file into my database. The problem is that in the very beginning of the development I was using windows so my csv file was written on ms office. So while importing there it works fine. But switching to linux(UBUNTU) while saving the csv file it's not showing data as i want. I'm not getting any solution either. This is the array which is generated by the csv that has been made by ms office on windows machine which works fine. Array ( [0] => Array ( [0

Call to undefined function now()

99封情书 提交于 2019-12-25 16:20:48
问题 I'm using the Ion Auth library for the authentication system in a website I'm working on. It worked without any problem, but since yesterday I'm getting this error: PHP Fatal error: Call to undefined function now() in /home/carlo/public_html/website/application/models/ion_auth_model.php on line 996 The code in that line is this: $this->db->update($this->tables['users'], array('last_login' => now()), array('id' => $id)); I read that now() is a mysql function and in php you should use date(),