Category Archives: My notes

Get large tables information

1
2
3
4
5
6
7
8
9
SELECT CONCAT(table_schema, '.', table_name),
       CONCAT(ROUND(table_rows / 1000000, 2), 'M')                                    rows,
       CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G')                    DATA,
       CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G')                   idx,
       CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
       ROUND(index_length / data_length, 2)                                           idxfrac
FROM   information_schema.TABLES
ORDER  BY data_length + index_length DESC
LIMIT  10;

Pages

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
abstract class page{
    public $head;
    public $content;
    public $foot;

    function __construct($head, $content, $foot){
       $this->head = $head;
       $this->content = $content;
       $this->foot = $foot;
    }
   
    public function getPage(){
       $smarty = new Smarty();
    }  
}

class login extends page{
   public function __construct($data){
      parent::__construct("login head", $data, "login foot");
   }
}
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
class talker{

    private $data = 'Hi';

    public function & get(){
        return $this->data;
    }
   
    public function out(){
        echo $this->data;
    }    

}

$aa = new talker();
$d = &$aa->get();

$aa->out();
$d = 'How';
$aa->out();
$d = 'Are';
$aa->out();
$d = 'You';
$aa->out();
?>

Create levels downline list

Create table with referrer id, if using down line will encounter multiple to one problem.  So I am using referrer id point to member upline, 1 as basic system id. One member only have one reference member,  one member can referrer more than one member.

Table Member:

Member_id Referrer_id
25 1
123 25
136 25
150 123
154 25

Here is one example how I grab member_id as 25 ‘s all downline.

1
$q = "SELECT member_id FROM members WHERE referrer_id = 25;"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!--?php
   function getTotal($products_costs, $tax) {
       $total = 0.00;
       $callback =
             function ($pricePerItem) use ($tax, &amp;$total)
             {
                  $total += $pricePerItem * ($tax + 1.0);
             };
       array_walk($products_costs, $callback);
       return round($total, 2);
}
 -------------------------------------------------------------------------
function slashit(&$aray, $db_link) {
     foreach ($aray as $key => &$value){
         if(is_array($value)) slashit($value, $link);
         else $aray[$key] = mysql_real_escape_string($value, $db_link);
     }
}
// Test: $fruits = array (
"fruits"  => array("a" => "or'ange", "b" => "ban'ana", "c" => "apple'"),
 "numbers" => array(1, 2, 3, 4, 5, 6),
 "holes"   => array("fir'st", 5 => "sec'ond", "thir'd"),
 "odma"    => "jugo'slavija"
);
?-->

Create mysql all datases tables fields head cvs file

mysqldump –skip-lock-tables -u root -t -T ‘/your files saved path’ information_schema COLUMNS –fields-enclosed-by=\”  –fields-terminated-by=,