Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coding style #46

Open
linroex opened this issue Feb 8, 2016 · 2 comments
Open

coding style #46

linroex opened this issue Feb 8, 2016 · 2 comments
Assignees

Comments

@linroex
Copy link
Collaborator

linroex commented Feb 8, 2016

    namespace Database;
    class Column{

        private $field;

        private $type;

        private $extra;

        private $not_null;

        private $primary_key;

        private $unique_key;

        private $foreign_key;

應該寫成:

    namespace Database;

    class Column{
        private $field;
        private $type;
        private $extra;
        private $not_null;
        private $primary_key;
        private $unique_key;
        private $foreign_key;

分段落

通常 namespace 會跟 class 分開

@linroex
Copy link
Collaborator Author

linroex commented Feb 8, 2016

datebase.php

namespace Database;
use \PDO;
use \Exception;

改成

namespace Database;

use \PDO;
use \Exception;

@linroex
Copy link
Collaborator Author

linroex commented Feb 8, 2016

install.php

function loadDataToTableFromCSV($db, $tableName, $filename){
    $datas = []; //ther storage for datas;

    if (($handle = fopen("data_csv/" . $filename, "r")) !== FALSE) {
        $datafields = fgetcsv($handle, 1000, ",");

        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            array_push($datas, $data);
        }

        fclose($handle);

        try {
            $db->insertIntoTable_batch($tableName, $datafields, $datas);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }else{
        throw new Exception("loadDataToTableFromCSV(): this file can't open!", 1);
    }
}

程式碼分段

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants