模型
function get_prices()
{
$table_by_product = 'printer_businesscards'; //replace with URI Segment
//Get all the columns in the table set by the page URI of $table_by_product variable
$get_all_col_names = $this->db->list_fields($table_by_product);
//Loop through the column names. All names starting with 'O_' are optional fields for the
//current product. Get all Distinct values and create a radio button list in form.
foreach ($get_all_col_names as $key => $value) {
//get all o_types for the product by column name
if ($all_O_types = preg_match('/O_/', $value))
{
$O_types = array($value);
foreach ($O_types as $O) {
//echo $O;
$this->db->select($O);
$this->db->distinct();
$qO = $this->db->get($table_by_product);
$qO_Array = $qO->result_object();
}
}
//Get all x_types for the product by column name. All 'X_' types are specific product options.
//Create a dropdown menu with all DISTINCT product options.
if ($all_X_types = preg_match('/X_/', $value))
{
$X_types = array($value);
foreach ($X_types as $X) {
//echo $X;
$this->db->select($X);
$this->db->distinct();
$qX = $this->db->get($table_by_product);
$qX_Array = $qX->result_object();
}
}
}
return array($qX_Array,$qO_Array);
}
}
所以每个产品都有不同的选项,但所有产品选项都以“X_”或“O_”为前缀。我需要获取DISTINCT
“X_”和“O_”的每个 COLUMN 的值,并且在任何视图中我需要使用这些值构建一个表单。下面看一下数组:
array (size=3)
0 =>
object(stdClass)[19]
public 'X_SIZE' => string '1.75x3' (length=6)
1 =>
object(stdClass)[20]
public 'X_SIZE' => string '1.75x3.5(slim)' (length=14)
2 =>
object(stdClass)[21]
public 'X_SIZE' => string '2x3' (length=3)
array (size=3)
0 =>
object(stdClass)[17]
public 'X_PAPER' => string '14ptGlossCoatedCoverwithUV(C2S)' (length=31)
1 =>
object(stdClass)[18]
public 'X_PAPER' => string '14ptPremiumUncoatedCover' (length=24)
2 =>
object(stdClass)[24]
public 'X_PAPER' => string '16ptDullCoverwithMatteFinish' (length=28)
array (size=2)
0 =>
object(stdClass)[23]
public 'X_COLOR' => string '1000' (length=4)
1 =>
object(stdClass)[22]
public 'X_COLOR' => string '1002' (length=4)
array (size=4)
0 =>
object(stdClass)[20]
public 'X_QTY' => string '100' (length=3)
1 =>
object(stdClass)[21]
public 'X_QTY' => string '250' (length=3)
2 =>
object(stdClass)[17]
public 'X_QTY' => string '500' (length=3)
3 =>
object(stdClass)[19]
public 'X_QTY' => string '1000' (length=4)
array (size=3)
0 =>
object(stdClass)[25]
public 'O_RC' => string 'YES' (length=3)
1 =>
object(stdClass)[26]
public 'O_RC' => string 'NO' (length=2)
2 =>
object(stdClass)[27]
public 'O_RC' => string 'NA' (length=2)
我的电流MODEL
只是回到我X_QTY
的O_RC
视野。
我做错了什么?