codeigniter-datamapper

Jquery parse xhr.responseText

断了今生、忘了曾经 提交于 2019-12-12 02:57:47
问题 var data = xhr.responseText; When I output this console.log(xhr.responseText) . Below is my output ["{id:1,name\":\"JOHN\",\"city\":\"null\"}" ,"{\"id\":2,\"name\":\"MICHEAL\,\"city\":\"null\"}"] How do I get id , name . I tried like this data.id but I get this error jquery JSON.parse: unexpected end of data. Update I am using code igniter with data mapper so my data mapper is giving that json response. Do you know, how I can resolve it. 回答1: You've already been told what the problem is in

URL having parentheses not working in codeigniter with datamapper ORM

限于喜欢 提交于 2019-12-12 02:05:53
问题 I'm using codeigniter with datamapper ORM, today I've noticed a strange error. I have a function named categories, which links from item page. url to category is formed using the name of the category and is encoded using rawurlencode. In category method I decode this url string and find the category using get_by_name. this works well except when the name of the category includes parentheses suppose I have a item "ABCDEFGHI" which belongs to category "Alphabets (English)". now category after

DataMapper all_to_json() method returning slashes

柔情痞子 提交于 2019-12-11 20:19:20
问题 I just found DataMapper for CI's built in to_json and all_to_json methods, which saved me a ton of time. How can I return relations with the result? Currently my code looks like this: $homes = new Home(); $homes->include_related('address')->get(); $homes->include_related('album')->get(); $homes->get(); $homes->set_json_content_type(); echo $homes->to_json(); However I'm only getting back the home itself, rather than the nested information. EDIT: I've found that you can simply add those fields

How to insert into a table join other table using Activerecord in CodeIgniter?

徘徊边缘 提交于 2019-12-11 19:35:51
问题 I'm new to CodeIgniter and ORM, I hope you guys can help me with this. The question table: CREATE TABLE `question` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(128) NOT NULL DEFAULT '', `content` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; The answer table: CREATE TABLE `answer` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `question_id` int(11) unsigned NOT NULL, `content` text NOT NULL, PRIMARY KEY (`id`), KEY `question_id` (`question_id`

Compare two dates in Codeigniter and MySQL

廉价感情. 提交于 2019-12-11 00:49:27
问题 How can I get values between two dates in Codeigniter query function? Here is my model and sample code. function get_promo() { $today = date('Y-m-d'); $query = $this->db->query('SELECT FROM tbl_event WHERE event_id = $id AND event_startdate <= $today AND event_enddate >= $today'); return $query; } But it doesn't work, here is the error I got A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the

Error: You must use the “set” method to update an entry fix?

本小妞迷上赌 提交于 2019-12-03 16:34:22
I am using codeigniter as my PHP framework, and I keep getting this error when I submit my from to post to my database. You must use the "set" method to update an entry I am not exactly sure what that means, from the other posts I have looked at, everyone says that the datamapper needs to have a value assigned to the object. Being that I am new to all this, could someone give me a better explaniation. Here is my code where it says I have the error: class Add_book extends CI_Model { public function add_book($data){ $this->db->insert('ST_ITM', $data); } } ?> Thank you. You need to do something