/** * * @param type $sql = "INSERT INTO table SET field1 = '?', field2 = '?';" * @param array $params = ('Val1', 1, 6) * @param array $options - [resource 'dbo'] - 0ptional * @return MySqlQuery result object */ public static function execute($sql = '', array $params = array(), array $options = array()) { if ($sql == '') { throw new \Exception("Not a valid SQL."); } //just in case $options['connection'] = self::extractDbo($options); $MySql = new MySqlQuery($sql, $params, $options); if (!$MySql instanceof MySqlQuery) { throw new \Exception("Faild to create MySqlQuery object."); } return $MySql->getResult(); }
/** * Get array of only one field * * @param string $field_identifier * @param bool $is_numeric_identifier(true-$field_identifier is numeric, false-$field_identifier is a name) * @param int $offset * @param int $len * @return array */ public function fetchFields($field_identifier, $is_numeric_identifier = false, $offset = 0, $len = 0) { if ($this->is_result_cached) { $array_to_return = array(); foreach ($this->result as $key => $val) { if ($is_numeric_identifier) { $keys = array_keys($val); $array_to_return[] = $val[$keys[$field_identifier]]; } else { $array_to_return[] = $val[$field_identifier]; } } return $array_to_return; } else { return parent::fetchFields($field_identifier, $is_numeric_identifier, $offset, $len); } }