|
 |
|
รบกวนแปลความหมายของบรรทัดนี้ให้หน่อยครับ ขอบคุณครับ |
|
 |
|
|
 |
 |
|
เป็นแค่การอ่านชื่อ Column มาเก็บลงไว้ใน Array ครับ ซึ่งมันจะได้แบบนี้ครับ
Code (SQL)
CREATE TABLE `customer` (
`CustomerID` varchar(4) NOT NULL,
`Name` varchar(50) NOT NULL,
`Email` varchar(50) NOT NULL,
`CountryCode` varchar(2) NOT NULL,
`Budget` double NOT NULL,
`Used` double NOT NULL,
PRIMARY KEY (`CustomerID`)
) ENGINE=MyISAM;
--
-- Dumping data for table `customer`
--
INSERT INTO `customer` VALUES ('C001', 'Win Weerachai', '[email protected]', 'TH', 1000000, 600000);
INSERT INTO `customer` VALUES ('C002', 'John Smith', '[email protected]', 'EN', 2000000, 800000);
INSERT INTO `customer` VALUES ('C003', 'Jame Born', '[email protected]', 'US', 3000000, 600000);
INSERT INTO `customer` VALUES ('C004', 'Chalee Angel', '[email protected]', 'US', 4000000, 100000);
Code
$arrCol[CustomerID] = C001;
$arrCol[Name] = Win Weerachai;
.
.
.
array_push($resultArray,$arrCol); คือเอามันส่งไว้ใน Array $resultArra ครับ
มันจะได้ Result ของ Array เป็น
Code
array(4) {
[0]=>
array(12) {
[0]=>
string(4) "C001"
["CustomerID"]=>
string(4) "C001"
[1]=>
string(13) "Win Weerachai"
["Name"]=>
string(13) "Win Weerachai"
[2]=>
string(28) " [email protected]"
["Email"]=>
string(28) " [email protected]"
[3]=>
string(2) "TH"
["CountryCode"]=>
string(2) "TH"
[4]=>
string(7) "1000000"
["Budget"]=>
string(7) "1000000"
[5]=>
string(6) "600000"
["Used"]=>
string(6) "600000"
}
[1]=>
array(12) {
[0]=>
string(4) "C002"
["CustomerID"]=>
string(4) "C002"
[1]=>
string(11) "John Smith"
["Name"]=>
string(11) "John Smith"
[2]=>
string(25) " [email protected]"
["Email"]=>
string(25) " [email protected]"
[3]=>
string(2) "EN"
["CountryCode"]=>
string(2) "EN"
[4]=>
string(7) "2000000"
["Budget"]=>
string(7) "2000000"
[5]=>
string(6) "800000"
["Used"]=>
string(6) "800000"
}
[2]=>
array(12) {
[0]=>
string(4) "C003"
["CustomerID"]=>
string(4) "C003"
[1]=>
string(9) "Jame Born"
["Name"]=>
string(9) "Jame Born"
[2]=>
string(24) " [email protected]"
["Email"]=>
string(24) " [email protected]"
[3]=>
string(2) "US"
["CountryCode"]=>
string(2) "US"
[4]=>
string(7) "3000000"
["Budget"]=>
string(7) "3000000"
[5]=>
string(6) "600000"
["Used"]=>
string(6) "600000"
}
[3]=>
array(12) {
[0]=>
string(4) "C004"
["CustomerID"]=>
string(4) "C004"
[1]=>
string(12) "Chalee Angel"
["Name"]=>
string(12) "Chalee Angel"
[2]=>
string(27) " [email protected]"
["Email"]=>
string(27) " [email protected]"
[3]=>
string(2) "US"
["CountryCode"]=>
string(2) "US"
[4]=>
string(7) "4000000"
["Budget"]=>
string(7) "4000000"
[5]=>
string(6) "100000"
["Used"]=>
string(6) "100000"
}
}
เพื่อที่จะเอามันไปแปลงให้เป็น JSON ครับ
Go to : php กับการนำ array_push มาเก็บค่า result ของ mysql ที่ได้จากการ query และ fetch array
|
 |
 |
 |
 |
Date :
2013-02-28 15:59:09 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ชัดเจนครับ ขอบคุณครับ 
|
 |
 |
 |
 |
Date :
2013-02-28 16:17:56 |
By :
Ex-[S]i[L]e[N]t |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|