コード例 #1
0
ファイル: My_SQL.php プロジェクト: noblejay/Sweet-Framework
	function query($sql, $returnType=null) {
		if($this->prepared == false) {
			$this->prepare($sql);
		}
		//echo "\n SQL call = " . $sql . "\n";
		
		$this->queries[] = $sql;
	//	$this->result = $this->connection->query($sql);
		D::log("\n" . $sql, 'SQL call');
		
		$this->result = mysql_query($sql, $this->connection);
		
		$this->prepared = false;
		
		if(!$this->result) {
			D::stack();
			D::log(mysql_error($this->connection), 'SQL Errors');
			return false;
		}
		
		$returnArray = array();
/* 	@todo
get rid of this switch and use an array of functions instead.
	 */
	 	if(!isset($returnType)) {
	 		return true;
	 	}
		switch ($returnType) {
			case 'object':
				if(!is_resource($this->result)) {
					D::stackTrace();
				}
				while($row = mysql_fetch_object($this->result)) {
					$returnArray[] = $row;
				}
				return $returnArray;
					
				
				break;
			case 'assoc':
				while($row = mysql_fetch_assoc($this->result)) {
					$returnArray[] = $row;
				}
				return $returnArray;
				break;
			case 'driver':
				return $this->result;
			break;
			case 'raw':
				return $this->result;
				break;
			default:
				return true;
		}
	}
コード例 #2
0
	function _buildPull($pull, $pullRel, $tableName, $lfName=null, $rfName=null) {
		$select = $join = array();
		//JOIN CODE:
		
		if(is_array($tableName)) {
			$tableName = join('$', ($tableName));
		}
		
		if(is_array($lfName)) {
			//D::log($pull, '$pull aka $k');
			//D::log($lfName, 'lfName');
			D::stack('is_array($lfName)');
		}
		
		$join[$this->tableName . ' AS ' . $pull] = array(
			$tableName . '.' . $lfName => $pull . '.' . $rfName
		);
		
		//SELECT CODE:
		foreach(array_keys($this->fields) as $field) {
			//$select[$pull . '.' . $field] = str_replace('$', '.', $pull) . '.' . $field;
			$select[str_replace('$', '.', $pull) . '.' . $field] = $pull . '.' . $field;
		}
	//	D::log($select, 'built select');
		return array(
			'join' => $join,
			'select' => $select
		);
	}	
コード例 #3
0
ファイル: D.php プロジェクト: noblejay/Sweet-Framework
	static function warn($warning='Warning') {
		//D::show('WHAT');
		if(self::$config['warnings']) {
			if(!extension_loaded('xdebug')) {
				D::show(D::stack(), $warning);
			}
			trigger_error($warning);
		}		
	}