This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function get_todo($id) { | |
| if(is_numeric($id) && !empty($id)) { | |
| $sql = 'select * from todo where todo_id = '.$id; | |
| return json(db($sql)); | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function add_todo() { | |
| $todo_title = mysql_real_escape_string($_POST['todo_title']); | |
| $todo_text = (empty($_POST['todo_text']))?$todo_title:mysql_real_escape_string($_POST['todo_text']); | |
| if(!empty($todo_title)) { | |
| $sql = 'insert into todo (todo_title,todo_text) values ("'.$todo_title.'","'.$todo_text.'")'; | |
| if(db($sql)) { | |
| return json(db('select todo_id from todo order by todo_id desc limit 1')); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function get_todo_list() { | |
| $sql = 'select todo_id, todo_title from todo where completed != 1'; | |
| return json(db($sql)); | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE DATABASE `lemondoo` DEFAULT CHARSET utf8; | |
| USE `lemondoo`; | |
| CREATE TABLE `todo` ( | |
| `todo_id` int(11) not null auto_increment, | |
| `todo_title` varchar(100), | |
| `todo_text` text, | |
| `completed` tinyint(4) default '0', | |
| PRIMARY KEY (`todo_id`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dg->modify('username', function($value,$row) { | |
| return 'modified - '.$row['user_id'].'|'.$value; | |
| }); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $res = db('select product_id,name,short_description from products order by name asc'); | |
| $dg = new OPCDataGrid($res); | |
| $dg->fields(array( | |
| 'name' => 'Product Name', | |
| 'short_description' => 'Description' | |
| )); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $data = array( | |
| array( | |
| 'user_id' => 1, | |
| 'username' => 'skywalkl', | |
| 'email' => '[email protected]' | |
| ), | |
| array( | |
| 'user_id' => 2, | |
| 'username' => 'solohan', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysqldump --user=username --password=1234 --databases your_database --opt --quote-names --allow-keywords --complete-insert > your_database.sql.bz2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * A quick little function to interact with a MySQL database. | |
| * | |
| * When working with Limonade-php a full-fledged MySQL wrapper seems like | |
| * overkill. This method instead accepts any mysql statement and if it works | |
| * returns either the result or the number of rows affected. If neither worked, | |
| * then it returns false | |
| * | |
| * @param string $sql the sql statement you want to execute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function configure() { | |
| $c = mysql_connect('localhost','root',''); | |
| $s = mysql_select_db('todo',$c); | |
| } | |
| ?> |