Category Archives: Uncategorized

Delete records from multiple tables

This is sample query to delete record from multiple tables.

Specify all joined tables to get the list but can specify records in which tables to be deleted.

DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id;

OR

DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id;

Reference

https://dev.mysql.com/doc/refman/8.0/en/delete.html (refer section – Multi-Table Deletes)

MySQL Error Code 1166. Incorrect column name

Got this error while importing csv to table in MySQL database using sequel pro.

This error normally because of extra space in field name that mysql cannot accept.

But sometimes you just can’t find where is the extra space.

One way to solve is add additional column, when import, just ignore the last field and you can import it as usual.

Foolproof system

To build a foolproof and super easy to maintain system must be a goal for a system development.

To get to that, it has to have

  1. clear naming standard and convention. e.g. no $i or $anumber kind of variable
  2. clear and easy to read code structure
  3. many small and structured files over one huge file
  4. heavily tested before deploy to live server and start being used by the users
  5. good database design to cater for growth
  6. good settings and configurations either on files or database so it is flexible

Asana workflow

Asana is a  proficient tool to manage tasks in a small team.

Below is the suggested workflow to be followed

  1. Task created by manager or assignee (if the task is assigned offline or via other medium)
  2. Assign to assignee
  3. Assignee comment “in progress” when start processing a task
  4. Assignee and manager communicate in comments for particular task
  5. To add “follower” if need some other people to be in the loop
  6. Assignee assign to manager back once the task complete for verification before can be marked as complete
  7. Manager will verify, set as complete and set the assignee back for record as person who has done the job. Or if it is not complete, task will be assigned back to the assignee

Basic git flow

Basic git flow

from remote “master”, create a branch “develop”.

pull branch “develop”

branch out branch “feature” or “bug” from local “develop”

commit changes to branch”feature”

push branch”feature” to remote branch”feature”

request merge to remote branch “develop”

after merged, pull branch “develop” to local

 

Billplz Notes

Billplz is a malaysian’s payment gateway. It’s free to register, easy to setup and affordable.

Register free here

If you are using postman to test, add the API Key as username in Authorization tab. Choose “Basic Auth” in Type dropdown. Then enter the URL and params as usual

 

Free tools for small businesses

Some free tools you can use to start your business. The providers normally provide the free tools for basic usage. Some limitation on features and users. But if you are small, it doesn’t matter much. At least you can start with some cool softwares to support your small business

CRM – hubspot

Support Ticket/ Help Desk – freshdesk

Accounting – waveapps – need to pay to use payroll and payments

Version control – GitLab

Multiple database in CodeIgniter

How to connect to more than one database in codeigniter

Database config

$db[‘default’][‘hostname’] = “localhost”;
$db[‘default’][‘username’] = “root”;
$db[‘default’][‘password’] = “”;
$db[‘default’][‘database’] = “database_name”;
$db[‘default’][‘dbdriver’] = “mysql”;

set another config for 2nd database

$db[‘otherdb’][‘hostname’] = “localhost”;
$db[‘otherdb’][‘username’] = “root”;
$db[‘otherdb’][‘password’] = “”;
$db[‘otherdb’][‘database’] = “other_database_name”;
$db[‘otherdb’][‘dbdriver’] = “mysql”;

Sample to call

//Load another database
$DB2 = $this->load->database(‘another_db’, TRUE);

//Default database query
$this->db->select(‘first_name, last_name’);
$this->db->from(‘users’);
$this->db->where(‘id’, 99);
$query = $this->db->get();

//Another database query
$DB2->select(‘image’);
$DB2->from(‘cdn_images’);
$DB2->where(‘id’, 25);
$query = $DB2->get();

 

References

codexworld.com/connect-use-multiple-database-codeigniter

 

Ionic notes

Some notes on ionic CLI command

Create new project (will create myApp directory):

> ionic start myApp blank

(besides blank, there is option to use other template like tabs, sidemenu, tutorial, super)

  • tabs : a simple 3 tab layout
  • sidemenu: a layout with a swipable menu on the side
  • blank: a bare starter with a single page
  • super: starter project with over 14 ready to use page designs
  • tutorial: a guided starter project

Get into the directory and start service

> ionic serve

Launch editor to start coding

> atom .

Other resources

  1. ionic framework doc
  2. ionic crashed course video (~30 minutes)