//数组赋值问题
$_a = array(1,2,3,4,5);
$_b = array('a','b','c','d','e');
$_data = array();
//如果想把$_a,$_b添加到 数组$_data中,
//不可以使用
$_data = $_a;
echo $_data; //array(1,2,3,4,5)
$_data = $_b;
echo $_data; //array('a','b','c','d','e')
//并不是array((1,2,3,4,5),('a','b','c','d','e'))
//因为这是简单的赋值,并不是添加,正确的写法如下
$_data[] = $_a;
$_data[] = $_b;
echo $_data; //array((1,2,3,4,5),('a','b','c','d','e'))
1.对于多张表左连接,用法和两张表是一样的
$sql = "SELECT
a.id,a.name,b.score,c.level
FROM ec_orders AS a
LEFT JOIN ec_account AS b ON a.id = b.id
LEFT JOIN ec_goods_brands AS c ON a.brands_id = c.id
WHERE a.is_del = 0 AND b.is_del = 0 AND c.is_del = 0";
a.id,a.name,b.score,c.level 是你想要查找出来的数据,注意的地方是前缀表别名(a,b,c)不要忘了添加,否则会因为无法知道去查询哪张表而报错,
LEFT JOIN ec_account AS b ON a.id = b.id 左连接查询 a,b两张表相同id的记录,
LEFT JOIN ec_goods_brands AS c ON a.id = c.id 同理
WHERE为条件判断语句