/// <summary> /// Gets a PHP object whose properties describes a specified field. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <param name="fieldIndex">Field index.</param> /// <returns>The PHP object.</returns> public static stdClass mssql_fetch_field(PhpResource resultHandle, int fieldIndex = -1) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(null); } if (fieldIndex < 0) { fieldIndex = result.FetchNextField(); } //DataRow info = result.GetSchemaRowInfo(fieldIndex); //if (info == null) return null; //string s; string php_type = result.GetPhpFieldType(fieldIndex); var arr = new PhpArray(5); arr.Add("name", result.GetFieldName(fieldIndex)); //arr.Add("column_source", (s = info["BaseColumnName"] as string) != null ? s : ""); // TODO: column_source arr.Add("max_length", result.GetFieldLength(fieldIndex)); arr.Add("numeric", result.IsNumericType(php_type) ? 1 : 0); arr.Add("type", php_type); return((stdClass)arr.ToClass()); }
/// <summary> /// Gets a contents of a specified cell from a specified query result resource. /// </summary> /// <param name="ctx">PHP context.</param> /// <param name="resultHandle">Query result resource.</param> /// <param name="rowIndex">Row index.</param> /// <param name="field">Column (field) integer index or string name.</param> /// <returns>The value of the cell or <B>false</B> on failure (invalid resource or row index).</returns> public static PhpValue mssql_result(Context ctx, PhpResource resultHandle, int rowIndex, PhpValue field) { var result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(PhpValue.False); } string field_name; object field_value; if (field.IsNull) { field_value = result.GetFieldValue(rowIndex, result.CurrentFieldIndex); } else if ((field_name = PhpVariable.AsString(field)) != null) { field_value = result.GetFieldValue(rowIndex, field_name); } else { field_value = result.GetFieldValue(rowIndex, (int)field.ToLong()); } if (field_value == null) { return(PhpValue.False); } return(PhpValue.FromClr(field_value)); // Core.Convert.Quote(field_value, context); }
/// <summary> /// Sets the result resource's current row index. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <param name="rowIndex">New row index.</param> /// <returns><B>true</B> on success, <B>false</B> on failure (invalid resource or row index).</returns> public static bool mssql_data_seek(PhpResource resultHandle, int rowIndex) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(false); } return(result.SeekRow(rowIndex)); }
/// <summary> /// Sets the result resource's current column (field) offset. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <param name="fieldOffset">New column offset.</param> /// <returns><B>true</B> on success, <B>false</B> on failure (invalid resource or column offset).</returns> public static bool mssql_field_seek(PhpResource resultHandle, int fieldOffset) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(false); } return(result.SeekField(fieldOffset)); }
/// <summary> /// Gets a length of a specified column (field) in a result. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <param name="fieldIndex">Column index.</param> /// <returns>Length of the column or a -1 on failure (invalid resource or column index).</returns> public static int mssql_field_length(PhpResource resultHandle, int fieldIndex) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(-1); } return(result.GetFieldLength(fieldIndex)); }
/// <summary> /// Gets a type of a specified column (field) in a result. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <param name="fieldIndex">Column index.</param> /// <returns>MSSQL type translated to PHP terminology.</returns> /// <remarks> /// Possible values are: TODO. /// </remarks> public static string mssql_field_type(PhpResource resultHandle, int fieldIndex) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(null); } return(result.GetPhpFieldType(fieldIndex)); }
/// <summary> /// Gets a name of the current column (field) in a result. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <returns>Name of the column or a <B>null</B> reference on failure (invalid resource or column index).</returns> public static string mssql_field_name(PhpResource resultHandle) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(null); } return(result.GetFieldName()); }
/// <summary> /// Fetches the next result set if the query returned multiple result sets. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <returns>Whether the next result set is available.</returns> public static bool mssql_next_result(PhpResource resultHandle) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(false); } return(result.NextResultSet()); }
/// <summary> /// Get number of rows in a specified result. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <returns>Number of rows in the specified result or 0 if the result resource is invalid.</returns> public static int mssql_num_rows(PhpResource resultHandle) { PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(0); } return(result.RowCount); }
public static stdClass mssql_fetch_object(PhpResource resultHandle) { var result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(null); } return(result.FetchObject()); }
/// <summary> /// Releases a resource represening a query result. /// </summary> /// <param name="resultHandle">Query result resource.</param> /// <returns><B>true</B> on success, <B>false</B> on failure (invalid resource).</returns> public static bool mssql_free_result(PhpResource resultHandle) { var result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(false); } result.Dispose(); return(true); }
public static PhpArray mssql_fetch_array(PhpResource resultHandle, QueryResultKeys resultType = QueryResultKeys.Both) { var result = PhpSqlDbResult.ValidResult(resultHandle); if (result == null) { return(null); } switch (resultType) { case QueryResultKeys.ColumnNames: return(result.FetchArray(false, true)); case QueryResultKeys.Numbers: return(result.FetchArray(true, false)); case QueryResultKeys.Both: return(result.FetchArray(true, true)); } return(null); }
/// <summary> /// Executes a specified stored procedure statement. /// </summary> /// <param name="statement">Statement resource (stored procedure).</param> /// <param name="skipResults">Whether to retrieve and return procedure output.</param> /// <returns> /// Result resource containing procedure output, /// <B>true</B> if the procedure succeeded yet doesn't return any value, or /// <B>false</B> on failure. /// </returns> public static object mssql_execute(PhpResource statement, bool skipResults = false) { PhpSqlDbProcedure procedure = PhpSqlDbProcedure.ValidProcedure(statement); if (procedure == null) { return(false); } bool success; PhpSqlDbResult result = procedure.Execute(skipResults, out success); if (!success) { return(false); } if (skipResults) { return(true); } return(result); }